Documentation
¶
Overview ¶
Package llm provides a unified interface for Large Language Model providers. It abstracts different LLM providers (Anthropic Claude, OpenAI GPT) behind a common Thread interface for consistent interaction patterns.
Index ¶
- Constants
- func CloseThread(thread llmtypes.Thread) error
- func ExtractConversationEntries(provider string, rawMessages []byte, metadata map[string]any, ...) ([]conversations.StreamableMessage, error)
- func ExtractMessages(provider string, rawMessages []byte, metadata map[string]any, ...) ([]llmtypes.Message, error)
- func GetConfigFromViper() (llmtypes.Config, error)
- func GetConfigFromViperWithCmd(cmd *cobra.Command) (llmtypes.Config, error)
- func GetConfigFromViperWithEnvironmentProfile(profileName string) (llmtypes.Config, error)
- func GetConfigFromViperWithProfile(profileName string) (llmtypes.Config, error)
- func GetConfigFromViperWithProfileAndCmd(profileName string, cmd *cobra.Command) (llmtypes.Config, error)
- func GetConfigFromViperWithProfileAndCmdIgnoringFlags(profileName string, cmd *cobra.Command, ignoredFlags ...string) (llmtypes.Config, error)
- func GetConfigFromViperWithoutProfile() (llmtypes.Config, error)
- func GetConfigFromViperWithoutProfileAndCmd(cmd *cobra.Command) (llmtypes.Config, error)
- func GetConfigFromViperWithoutProfileAndCmdIgnoringFlags(cmd *cobra.Command, ignoredFlags ...string) (llmtypes.Config, error)
- func GlobalProfileSetting() string
- func GlobalProfiles() map[string]llmtypes.ProfileConfig
- func HasConfiguredProfile(profileName string) bool
- func NewThread(config llmtypes.Config) (llmtypes.Thread, error)
- func OverrideProfileSetting() (string, bool)
- func OverrideProfiles() map[string]llmtypes.ProfileConfig
- func ProfileSources() map[string]ProfileSource
- func RenderConversationMarkdown(provider string, rawMessages []byte, metadata map[string]any, ...) (string, error)
- func RenderConversationMarkdownWithOptions(provider string, rawMessages []byte, metadata map[string]any, ...) (string, error)
- func RepoProfileSetting() string
- func RepoProfiles() map[string]llmtypes.ProfileConfig
- func SendMessageAndGetText(ctx context.Context, state tooltypes.State, query string, ...) string
- func SendMessageAndGetTextWithUsage(ctx context.Context, state tooltypes.State, query string, ...) (string, llmtypes.Usage)
- func SetEnvironment(thread llmtypes.Thread, environment agentenv.Environment) error
- func UsesIsolatedConfigFile() bool
- type ConversationMarkdownOptions
- type ProfileSource
Constants ¶
const ( DefaultMaxToolResultCharacters = conversations.DefaultMaxToolResultCharacters DefaultMaxToolResultBytes = conversations.DefaultMaxToolResultBytes )
const ( // ConfigFileEnv points at an additional trusted configuration file that is // layered on top of the global config, or replaces it entirely in isolated mode. ConfigFileEnv = "KODELET_CONFIG_FILE" // ConfigFileModeEnv selects how ConfigFileEnv is applied. ConfigFileModeEnv = "KODELET_CONFIG_FILE_MODE" // ConfigFileModeMerge layers the override file on top of the global config. ConfigFileModeMerge = "merge" // ConfigFileModeIsolated makes the override file the only configuration source. ConfigFileModeIsolated = "isolated" // RepoConfigFile is the repository-local configuration file name. RepoConfigFile = "kodelet-config.yaml" ProfileSourceGlobal ProfileSource = "global" ProfileSourceRepo ProfileSource = "repo" ProfileSourceRepoOverridesGlobal ProfileSource = "repo-overrides-global" ProfileSourceOverride ProfileSource = "override" )
Variables ¶
This section is empty.
Functions ¶
func CloseThread ¶
CloseThread releases provider-specific resources owned by a thread. Providers without explicit resources do not need to implement Close.
func ExtractConversationEntries ¶
func ExtractConversationEntries(provider string, rawMessages []byte, metadata map[string]any, toolResults map[string]tooltypes.StructuredToolResult) ([]conversations.StreamableMessage, error)
ExtractConversationEntries parses the raw messages from a conversation record into structured conversation entries.
func ExtractMessages ¶
func ExtractMessages(provider string, rawMessages []byte, metadata map[string]any, toolResults map[string]tooltypes.StructuredToolResult) ([]llmtypes.Message, error)
ExtractMessages parses the raw messages from a conversation record
func GetConfigFromViper ¶
GetConfigFromViper loads the LLM configuration from Viper, applies the active profile if set, and resolves any model aliases.
func GetConfigFromViperWithCmd ¶
GetConfigFromViperWithCmd loads the LLM configuration from Viper with command context. When a cobra.Command is provided, CLI flags that were explicitly changed take priority over profile settings.
func GetConfigFromViperWithEnvironmentProfile ¶
GetConfigFromViperWithEnvironmentProfile loads runner-owned configuration from the separate environment_profiles namespace without applying a model profile.
func GetConfigFromViperWithProfile ¶
GetConfigFromViperWithProfile loads configuration from Viper while applying the provided profile name instead of the globally active viper profile. This is useful for request-scoped profile selection (for example, in the web UI) without mutating shared process-wide viper state.
func GetConfigFromViperWithProfileAndCmd ¶
func GetConfigFromViperWithProfileAndCmd(profileName string, cmd *cobra.Command) (llmtypes.Config, error)
GetConfigFromViperWithProfileAndCmd loads configuration from Viper while applying the provided profile name and then re-applying any explicitly changed Cobra flags on top.
func GetConfigFromViperWithProfileAndCmdIgnoringFlags ¶
func GetConfigFromViperWithProfileAndCmdIgnoringFlags(profileName string, cmd *cobra.Command, ignoredFlags ...string) (llmtypes.Config, error)
GetConfigFromViperWithProfileAndCmdIgnoringFlags applies a named profile and all explicit Cobra flags except the supplied persisted-field flags.
func GetConfigFromViperWithoutProfile ¶
GetConfigFromViperWithoutProfile loads configuration from Viper without applying any active profile from shared process state.
func GetConfigFromViperWithoutProfileAndCmd ¶
GetConfigFromViperWithoutProfileAndCmd loads configuration without an active profile, then reapplies explicitly changed Cobra flags.
func GetConfigFromViperWithoutProfileAndCmdIgnoringFlags ¶
func GetConfigFromViperWithoutProfileAndCmdIgnoringFlags(cmd *cobra.Command, ignoredFlags ...string) (llmtypes.Config, error)
GetConfigFromViperWithoutProfileAndCmdIgnoringFlags is the request-scoped variant used when persisted conversation fields must remain authoritative.
func GlobalProfileSetting ¶
func GlobalProfileSetting() string
GlobalProfileSetting returns the active profile selected by the global configuration layer.
func GlobalProfiles ¶
func GlobalProfiles() map[string]llmtypes.ProfileConfig
GlobalProfiles returns the profiles declared by the global configuration layer. The built-in "default" profile is excluded, and nil is returned when no profile is declared or an isolated override disables the layer.
func HasConfiguredProfile ¶
HasConfiguredProfile reports whether a named profile exists in the merged Viper configuration.
func OverrideProfileSetting ¶
OverrideProfileSetting returns the profile selected by KODELET_CONFIG_FILE and whether that file explicitly contains a profile setting.
func OverrideProfiles ¶
func OverrideProfiles() map[string]llmtypes.ProfileConfig
OverrideProfiles returns the profiles declared by KODELET_CONFIG_FILE.
func ProfileSources ¶
func ProfileSources() map[string]ProfileSource
ProfileSources returns every available profile and the highest-precedence configuration layer that defines it.
func RenderConversationMarkdown ¶
func RenderConversationMarkdown( provider string, rawMessages []byte, metadata map[string]any, toolResults map[string]tooltypes.StructuredToolResult, ) (string, error)
RenderConversationMarkdown converts a stored conversation into markdown using the same formatting logic as `kodelet conversation show --format markdown`.
func RenderConversationMarkdownWithOptions ¶
func RenderConversationMarkdownWithOptions( provider string, rawMessages []byte, metadata map[string]any, toolResults map[string]tooltypes.StructuredToolResult, opts ConversationMarkdownOptions, ) (string, error)
RenderConversationMarkdownWithOptions converts a stored conversation into markdown with optional output-shaping controls.
func RepoProfileSetting ¶
func RepoProfileSetting() string
RepoProfileSetting returns the active profile selected by the repository-local config.
func RepoProfiles ¶
func RepoProfiles() map[string]llmtypes.ProfileConfig
RepoProfiles returns the profiles declared by the repository-local config.
func SendMessageAndGetText ¶
func SendMessageAndGetText(ctx context.Context, state tooltypes.State, query string, config llmtypes.Config, silent bool, opt llmtypes.MessageOpt) string
SendMessageAndGetText is a convenience method for one-shot queries that returns the response as a string
func SendMessageAndGetTextWithUsage ¶
func SendMessageAndGetTextWithUsage(ctx context.Context, state tooltypes.State, query string, config llmtypes.Config, silent bool, opt llmtypes.MessageOpt) (string, llmtypes.Usage)
SendMessageAndGetTextWithUsage is a convenience method for one-shot queries that returns the response as a string and usage information
func SetEnvironment ¶
func SetEnvironment(thread llmtypes.Thread, environment agentenv.Environment) error
SetEnvironment attaches an agent environment to a provider thread.
func UsesIsolatedConfigFile ¶
func UsesIsolatedConfigFile() bool
UsesIsolatedConfigFile reports whether an explicit override replaces both the home and repository configuration layers.
Types ¶
type ConversationMarkdownOptions ¶
type ConversationMarkdownOptions = conversations.MarkdownOptions
ConversationMarkdownOptions controls markdown rendering for stored conversations.
type ProfileSource ¶
type ProfileSource string
ProfileSource identifies the highest-precedence configuration layer for a profile.
func ActiveProfileSetting ¶
func ActiveProfileSetting() (string, ProfileSource)
ActiveProfileSetting returns the profile selected by the highest-precedence configuration file together with that file's source.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package anthropic provides a client implementation for interacting with Anthropic's Claude AI models.
|
Package anthropic provides a client implementation for interacting with Anthropic's Claude AI models. |
|
Package base provides shared functionality for LLM thread implementations.
|
Package base provides shared functionality for LLM thread implementations. |
|
Package openai provides OpenAI API client implementations.
|
Package openai provides OpenAI API client implementations. |
|
copilotdefaults
Package copilotdefaults builds OpenAI-compatible model defaults from the Copilot model catalog.
|
Package copilotdefaults builds OpenAI-compatible model defaults from the Copilot model catalog. |
|
preset/codex
Package codex provides preset configurations for Codex CLI models.
|
Package codex provides preset configurations for Codex CLI models. |
|
preset/openai
Package openai provides preset configurations for OpenAI models
|
Package openai provides preset configurations for OpenAI models |
|
responses
Package responses implements storage types for the OpenAI Responses API.
|
Package responses implements storage types for the OpenAI Responses API. |
|
Package prompts provides common prompt templates for LLM interactions including context compacting prompts and other reusable prompt text used throughout kodelet's LLM communication.
|
Package prompts provides common prompt templates for LLM interactions including context compacting prompts and other reusable prompt text used throughout kodelet's LLM communication. |