llms

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package llms provides unified support for interacting with different Language Models (LLMs) from various providers. Designed with an extensible architecture, the package facilitates seamless integration of LLMs with a focus on modularity, encapsulation, and easy configurability.

The package includes the following subpackages for LLM providers: 1. Hugging Face: llms/huggingface/ 2. Mistral: llms/mistral/ 3. OpenAI: llms/openai/ 4. Google AI: llms/googleai/ 5. Bedrock: llms/bedrock/ 6. Anthropic: llms/anthropic/ 7. Ollama: llms/ollama/ 8. Cache: llms/cache/ 10. Streaming: llms/streaming/ 11. Reasoning: llms/reasoning/ 12. Structured Output: llms/structuredoutput/

Each subpackage includes provider-specific LLM implementations and helper files for communication with supported LLM providers. The internal directories within these subpackages contain provider-specific client and API implementations.

The `llms.go` file contains the types and interfaces for interacting with different LLMs.

The `options.go` file provides various per-call options to configure the LLMs, including reasoning controls (WithReasoning, WithAdaptiveReasoning, WithReasoningDisabled) and provider-neutral schema-constrained output (WithStructuredOutput). The reasoning package resolves model capabilities for the former; the structuredoutput package validates responses for the latter.

Index

Constants

View Source
const (
	DefaultN                 = 1
	DefaultCandidateCount    = 1
	DefaultMaxTokens         = 16384
	DefaultTemperature       = 0.0
	DefaultTopK              = 0
	DefaultTopP              = 0
	DefaultMinP              = 0
	DefaultSeed              = 0
	DefaultMinLength         = 0
	DefaultMaxLength         = 0
	DefaultRepetitionPenalty = 0.0
	DefaultFrequencyPenalty  = 0.0
	DefaultPresencePenalty   = 0.0
	DefaultSpeed             = 0.0
)
View Source
const MaxReasoningTokens = 64000

Variables

View Source
var (
	// ErrAuthentication is returned when authentication fails.
	ErrAuthentication = &Error{Code: ErrCodeAuthentication}

	// ErrRateLimit is returned when rate limit is exceeded.
	ErrRateLimit = &Error{Code: ErrCodeRateLimit}

	// ErrInvalidRequest is returned for invalid requests.
	ErrInvalidRequest = &Error{Code: ErrCodeInvalidRequest}

	// ErrTimeout is returned when an operation times out.
	ErrTimeout = &Error{Code: ErrCodeTimeout}

	// ErrCanceled is returned when an operation is canceled.
	ErrCanceled = &Error{Code: ErrCodeCanceled}

	// ErrQuotaExceeded is returned when quota is exceeded.
	ErrQuotaExceeded = &Error{Code: ErrCodeQuotaExceeded}

	// ErrContentFilter is returned when content is filtered.
	ErrContentFilter = &Error{Code: ErrCodeContentFilter}

	// ErrTokenLimit is returned when token limit is exceeded.
	ErrTokenLimit = &Error{Code: ErrCodeTokenLimit}

	// ErrProviderUnavailable is returned when provider is unavailable.
	ErrProviderUnavailable = &Error{Code: ErrCodeProviderUnavailable}

	// ErrNotImplemented is returned when a feature is not implemented.
	ErrNotImplemented = &Error{Code: ErrCodeNotImplemented}
)

Common error variables for easy comparison.

View Source
var ErrStructuredOutputConfig = errors.New("structured output: invalid configuration")

ErrStructuredOutputConfig is the sentinel wrapped by every configuration error ValidateStructuredOutput reports (missing JSONMode, empty or non-object schema, malformed name). It is detectable without the network.

View Source
var ErrUnexpectedChatMessageType = errors.New("unexpected chat message type")

ErrUnexpectedChatMessageType is returned when a chat message is of an unexpected type.

Functions

func CalculateMaxTokens

func CalculateMaxTokens(model, text string) int

CalculateMaxTokens calculates the max number of tokens that could be added to a text.

func CountTokens

func CountTokens(model, text string) int

CountTokens gets the number of tokens the text contains.

func GenerateFromSinglePrompt

func GenerateFromSinglePrompt(ctx context.Context, llm Model, prompt string, options ...CallOption) (string, error)

GenerateFromSinglePrompt is a convenience function for calling an LLM with a single string prompt, expecting a single string response. It's useful for simple, string-only interactions and provides a slightly more ergonomic API than the more general llms.Model.GenerateContent.

func GetBufferString

func GetBufferString(messages []ChatMessage, humanPrefix string, aiPrefix string) (string, error)

GetBufferString gets the buffer string of messages.

func GetModelContextSize

func GetModelContextSize(model string) int

GetModelContextSize gets the max number of tokens for a language model. If the model name isn't recognized the default value 2048 is returned.

func IsAuthenticationError

func IsAuthenticationError(err error) bool

IsAuthenticationError returns true if the error is an authentication error.

func IsCanceledError

func IsCanceledError(err error) bool

IsCanceledError returns true if the error is a cancellation error.

func IsContentFilterError

func IsContentFilterError(err error) bool

IsContentFilterError returns true if the error is a content filter error.

func IsInvalidRequestError

func IsInvalidRequestError(err error) bool

IsInvalidRequestError returns true if the error is an invalid request error.

func IsNotImplementedError

func IsNotImplementedError(err error) bool

IsNotImplementedError returns true if the error is a not implemented error.

func IsProviderUnavailableError

func IsProviderUnavailableError(err error) bool

IsProviderUnavailableError returns true if the error is a provider unavailable error.

func IsQuotaExceededError

func IsQuotaExceededError(err error) bool

IsQuotaExceededError returns true if the error is a quota exceeded error.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the error is a rate limit error.

func IsTimeoutError

func IsTimeoutError(err error) bool

IsTimeoutError returns true if the error is a timeout error.

func IsTokenLimitError

func IsTokenLimitError(err error) bool

IsTokenLimitError returns true if the error is a token limit error.

func RegisterReasoningSupport

func RegisterReasoningSupport(pattern string, info ReasoningSupport)

RegisterReasoningSupport registers a UI hint for models this build does not classify (a proxy alias, or a model newer than this build). A model whose string contains pattern reports info from ReasoningSupportFor.

Scope: this affects ONLY the ReasoningSupportFor hint, not the wire path. The enable/disable resolvers (reasoning.ResolveOff, reasoning.ResolveClaudeAdaptive, effort clamping) live in the lower-level reasoning package, which cannot read this registry, so a registered model still travels the optimistic pass-through path on the wire and the provider API remains the final arbiter.

func ShowMessageContents

func ShowMessageContents(w io.Writer, msgs []MessageContent)

ShowMessageContents is a debugging helper for MessageContent.

Types

type AIChatMessage

type AIChatMessage struct {
	// Content is the content of the message.
	Content string `json:"content,omitempty"`

	// FunctionCall represents the model choosing to call a function.
	FunctionCall *FunctionCall `json:"function_call,omitempty"`

	// ToolCalls represents the model choosing to call tools.
	ToolCalls []ToolCall `json:"tool_calls,omitempty"`

	// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
	ReasoningContent string `json:"reasoning_content,omitempty"`
}

AIChatMessage is a message sent by an AI.

func (AIChatMessage) GetContent

func (m AIChatMessage) GetContent() string

func (AIChatMessage) GetFunctionCall

func (m AIChatMessage) GetFunctionCall() *FunctionCall

func (AIChatMessage) GetType

func (m AIChatMessage) GetType() ChatMessageType

type ApproximateLocation

type ApproximateLocation struct {
	// Country is the two-letter ISO country code (e.g., "US", "GB").
	Country string `json:"country,omitempty"`

	// City is the city name (e.g., "San Francisco", "London").
	City string `json:"city,omitempty"`

	// Region is the region or state (e.g., "California", "London").
	Region string `json:"region,omitempty"`
}

ApproximateLocation contains approximate location information.

type BinaryContent

type BinaryContent struct {
	MIMEType string `json:"mime_type,omitempty"`
	Data     []byte `json:"data"`
}

BinaryContent is content holding some binary data with a MIME type.

func BinaryPart

func BinaryPart(mime string, data []byte) BinaryContent

BinaryPart creates a new BinaryContent from the given MIME type (e.g. "image/png" and binary data).

func (BinaryContent) MarshalJSON

func (bc BinaryContent) MarshalJSON() ([]byte, error)

func (BinaryContent) String

func (bc BinaryContent) String() string

func (*BinaryContent) UnmarshalJSON

func (bc *BinaryContent) UnmarshalJSON(data []byte) error

type CacheControl

type CacheControl struct {
	Type     string        `json:"type,omitempty"`
	Duration time.Duration `json:"duration,omitempty"`
}

CacheControl represents prompt caching configuration for providers that support it.

func (CacheControl) String

func (cc CacheControl) String() string

type CallOption

type CallOption func(*CallOptions)

CallOption is a function that configures a CallOptions.

func WithAdaptiveReasoning

func WithAdaptiveReasoning(effort ReasoningEffort) CallOption

WithAdaptiveReasoning enables adaptive thinking (Claude 4.6+ models): the model decides how much to think and effort sets the level (low/medium/high/xhigh/max). Unlike WithReasoning there is no token budget, and the provider always omits sampling params (temperature/top_p) — Opus 4.7+ generations reject them.

func WithCandidateCount

func WithCandidateCount(c int) CallOption

WithCandidateCount specifies the number of response candidates to generate.

func WithFrequencyPenalty

func WithFrequencyPenalty(frequencyPenalty float64) CallOption

WithFrequencyPenalty will add an option to set the frequency penalty for sampling.

func WithFunctionCallBehavior

func WithFunctionCallBehavior(behavior FunctionCallBehavior) CallOption

WithFunctionCallBehavior will add an option to set the behavior to use when calling functions. Deprecated: Use WithToolChoice instead.

func WithFunctions

func WithFunctions(functions []FunctionDefinition) CallOption

WithFunctions will add an option to set the functions to include in the request. Deprecated: Use WithTools instead.

func WithJSONMode

func WithJSONMode() CallOption

WithJSONMode will add an option to set the response format to JSON. This is useful for models that return structured data.

func WithMaxLength

func WithMaxLength(maxLength int) CallOption

WithMaxLength will add an option to set the maximum length of the generated text.

func WithMaxTokens

func WithMaxTokens(maxTokens int) CallOption

WithMaxTokens specifies the max number of tokens to generate.

func WithMetadata

func WithMetadata(metadata map[string]interface{}) CallOption

WithMetadata will add an option to set metadata to include in the request. The meaning of this field is specific to the backend in use.

func WithMinLength

func WithMinLength(minLength int) CallOption

WithMinLength will add an option to set the minimum length of the generated text.

func WithMinP

func WithMinP(minP float64) CallOption

WithMinP will add an option to use min-p sampling.

func WithModel

func WithModel(model string) CallOption

WithModel specifies which model name to use.

func WithN

func WithN(n int) CallOption

WithN will add an option to set how many chat completion choices to generate for each input message.

func WithOptions

func WithOptions(options CallOptions) CallOption

WithOptions specifies options. Existing fields are copied shallowly (unchanged behavior); only the newer StructuredOutput is deep-cloned so the assembled option does not alias the caller's schema bytes.

func WithPresencePenalty

func WithPresencePenalty(presencePenalty float64) CallOption

WithPresencePenalty will add an option to set the presence penalty for sampling.

func WithReasoning

func WithReasoning(effort ReasoningEffort, tokens int) CallOption

WithReasoning sets the reasoning configuration for the model call. You can specify either the reasoning effort or the number of tokens to allocate for reasoning. If both effort is ReasoningNone and tokens is 0, reasoning will be disabled. Note: Most LLM providers expect only one of these options to be set at a time. Internally, the options may be converted between each other according to predefined rules.

func WithReasoningDisabled

func WithReasoningDisabled() CallOption

WithReasoningDisabled explicitly turns thinking off. Unlike omitting reasoning (which defers to the model default), this forces the provider's disable wire on models that support disabling — needed for models that think by default (e.g. Gemini 2.5, Claude 4.6). Models that cannot be disabled (adaptive-only Claude such as Fable 5, and OpenAI o-series) return a typed error from the provider.

func WithRepetitionPenalty

func WithRepetitionPenalty(repetitionPenalty float64) CallOption

WithRepetitionPenalty will add an option to set the repetition penalty for sampling.

func WithResponseFormat

func WithResponseFormat(responseFormat string) CallOption

WithResponseFormat will add an option to set the response format.

func WithResponseMIMEType

func WithResponseMIMEType(responseMIMEType string) CallOption

WithResponseMIMEType will add an option to set the ResponseMIMEType. Provider support varies - check your provider's documentation.

func WithSeed

func WithSeed(seed int) CallOption

WithSeed will add an option to use deterministic sampling.

func WithSpeed

func WithSpeed(speed float64) CallOption

WithSpeed will add an option to set the speed of the voice.

func WithStopWords

func WithStopWords(stopWords []string) CallOption

WithStopWords specifies a list of words to stop generation on.

func WithStreamingFunc

func WithStreamingFunc(streamingFunc streaming.Callback) CallOption

WithStreamingFunc specifies the streaming function to use.

func WithStructuredOutput

func WithStructuredOutput(config StructuredOutputConfig) CallOption

WithStructuredOutput requests provider-native, schema-constrained output for the call: the final response is a single JSON value matching config.Schema (raw JSON Schema, Draft 2020-12). It also sets JSONMode. The schema is copied, so mutating the caller's bytes afterwards does not change the option. Portable schemas should use a root object, list every property in required and set additionalProperties false recursively; each provider enforces its own subset, and the final response is validated against the original schema regardless. Support is opt-in and never changes wire behavior for callers that do not use it.

func WithTemperature

func WithTemperature(temperature float64) CallOption

WithTemperature specifies the model temperature, a hyperparameter that regulates the randomness, or creativity, of the AI's responses.

func WithToolChoice

func WithToolChoice(choice any) CallOption

WithToolChoice will add an option to set the choice of tool to use. It can either be "none", "auto" (the default behavior), or a specific tool as described in the ToolChoice type.

func WithTools

func WithTools(tools []Tool) CallOption

WithTools will add an option to set the tools to use.

func WithTopK

func WithTopK(topK int) CallOption

WithTopK will add an option to use top-k sampling.

func WithTopP

func WithTopP(topP float64) CallOption

WithTopP will add an option to use top-p sampling.

func WithVoice

func WithVoice(voice string) CallOption

WithVoice will add an option to set the voice to use.

func WithWebSearch

func WithWebSearch(options *WebSearchOptions) CallOption

WithWebSearch enables web search for models that support it. Use with OpenAI models like gpt-4o-search-preview and gpt-4o-mini-search-preview. Pass nil for default web search behavior, or provide WebSearchOptions to customize.

type CallOptions

type CallOptions struct {
	// Model is the model to use.
	Model *string `json:"model,omitempty"`
	// CandidateCount is the number of response candidates to generate.
	CandidateCount *int `json:"candidate_count,omitempty"`
	// MaxTokens is the maximum number of tokens to generate.
	MaxTokens *int `json:"max_tokens,omitempty"`
	// Temperature is the temperature for sampling, between 0 and 1.
	Temperature *float64 `json:"temperature,omitempty"`
	// StopWords is a list of words to stop on.
	StopWords []string `json:"stop_words,omitempty"`
	// StreamingFunc is a function to be called for each chunk of a streaming response.
	// Return an error to stop streaming early.
	StreamingFunc streaming.Callback `json:"-"`
	// TopK is the number of tokens to consider for top-k sampling.
	TopK *int `json:"top_k,omitempty"`
	// TopP is the cumulative probability for top-p sampling.
	TopP *float64 `json:"top_p,omitempty"`
	// MinP is the minimum probability for top-p sampling.
	MinP *float64 `json:"min_p,omitempty"`
	// Seed is a seed for deterministic sampling.
	Seed *int `json:"seed,omitempty"`
	// MinLength is the minimum length of the generated text.
	MinLength *int `json:"min_length,omitempty"`
	// MaxLength is the maximum length of the generated text.
	MaxLength *int `json:"max_length,omitempty"`
	// N is how many chat completion choices to generate for each input message.
	N *int `json:"n,omitempty"`
	// RepetitionPenalty is the repetition penalty for sampling.
	RepetitionPenalty *float64 `json:"repetition_penalty,omitempty"`
	// FrequencyPenalty is the frequency penalty for sampling.
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
	// PresencePenalty is the presence penalty for sampling.
	PresencePenalty *float64 `json:"presence_penalty,omitempty"`

	// Reasoning is the configuration for thinking of the model.
	Reasoning *ReasoningConfig `json:"reasoning,omitempty"`

	// JSONMode is a flag to enable JSON mode.
	JSONMode bool `json:"json"`

	// StructuredOutput requests provider-native, schema-constrained output. When
	// set (via WithStructuredOutput) JSONMode is also true and the provider is
	// asked for strict output matching Schema. nil keeps the legacy schema-less
	// JSON mode governed solely by JSONMode.
	StructuredOutput *StructuredOutputConfig `json:"structured_output,omitempty"`

	// Tools is a list of tools to use. Each tool can be a specific tool or a function.
	Tools []Tool `json:"tools,omitempty"`
	// ToolChoice is the choice of tool to use, it can either be "none", "auto" (the default behavior), or a specific tool as described in the ToolChoice type.
	ToolChoice any `json:"tool_choice,omitempty"`

	// Function defitions to include in the request.
	// Deprecated: Use Tools instead.
	Functions []FunctionDefinition `json:"functions,omitempty"`
	// FunctionCallBehavior is the behavior to use when calling functions.
	//
	// If a specific function should be invoked, use the format:
	// `{"name": "my_function"}`
	// Deprecated: Use ToolChoice instead.
	FunctionCallBehavior FunctionCallBehavior `json:"function_call,omitempty"`

	// Metadata is a map of metadata to include in the request.
	// The meaning of this field is specific to the backend in use.
	Metadata map[string]interface{} `json:"metadata,omitempty"`

	// ResponseMIMEType MIME type of the generated candidate text.
	// Supported MIME types are: text/plain: (default) Text output.
	// application/json: JSON response in the response candidates.
	ResponseMIMEType *string `json:"response_mime_type,omitempty"`

	// TTS options.
	Voice          *string  `json:"voice,omitempty"`
	Speed          *float64 `json:"speed,omitempty"`
	ResponseFormat *string  `json:"response_format,omitempty"`

	// WebSearchOptions configures web search behavior for models that support it.
	// Currently supported by OpenAI models like gpt-4o-search-preview.
	WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
}

CallOptions is a set of options for calling models. Not all models support all options.

func (*CallOptions) GetCandidateCount

func (o *CallOptions) GetCandidateCount() int

GetCandidateCount returns the number of response candidates to generate.

func (*CallOptions) GetFrequencyPenalty

func (o *CallOptions) GetFrequencyPenalty() float64

GetFrequencyPenalty returns the frequency penalty for sampling.

func (*CallOptions) GetFunctionCallBehavior

func (o *CallOptions) GetFunctionCallBehavior() FunctionCallBehavior

GetFunctionCallBehavior returns the behavior to use when calling functions.

func (*CallOptions) GetFunctions

func (o *CallOptions) GetFunctions() []FunctionDefinition

GetFunctions returns the functions to include in the request.

func (*CallOptions) GetJSONMode

func (o *CallOptions) GetJSONMode() bool

GetJSONMode returns the JSON mode flag.

func (*CallOptions) GetMaxLength

func (o *CallOptions) GetMaxLength() int

GetMaxLength returns the maximum length of the generated text.

func (*CallOptions) GetMaxTokens

func (o *CallOptions) GetMaxTokens() int

GetMaxTokens returns the max number of tokens to generate.

func (*CallOptions) GetMetadata

func (o *CallOptions) GetMetadata() map[string]interface{}

GetMetadata returns the metadata to include in the request.

func (*CallOptions) GetMinLength

func (o *CallOptions) GetMinLength() int

GetMinLength returns the minimum length of the generated text.

func (*CallOptions) GetMinP

func (o *CallOptions) GetMinP() float64

GetMinP returns the minimum probability for top-p sampling.

func (*CallOptions) GetModel

func (o *CallOptions) GetModel() string

GetModel returns the model to use.

func (*CallOptions) GetN

func (o *CallOptions) GetN() int

GetN returns how many chat completion choices to generate for each input message.

func (*CallOptions) GetPresencePenalty

func (o *CallOptions) GetPresencePenalty() float64

GetPresencePenalty returns the presence penalty for sampling.

func (*CallOptions) GetReasoning

func (o *CallOptions) GetReasoning() *ReasoningConfig

GetReasoning returns the reasoning configuration for the model call.

func (*CallOptions) GetRepetitionPenalty

func (o *CallOptions) GetRepetitionPenalty() float64

GetRepetitionPenalty returns the repetition penalty for sampling.

func (*CallOptions) GetResponseFormat

func (o *CallOptions) GetResponseFormat() string

GetResponseFormat returns the response format.

func (*CallOptions) GetResponseMIMEType

func (o *CallOptions) GetResponseMIMEType() string

GetResponseMIMEType returns the ResponseMIMEType.

func (*CallOptions) GetSeed

func (o *CallOptions) GetSeed() int

GetSeed returns the seed for deterministic sampling.

func (*CallOptions) GetSpeed

func (o *CallOptions) GetSpeed() float64

GetSpeed returns the speed of the voice.

func (*CallOptions) GetStopWords

func (o *CallOptions) GetStopWords() []string

GetStopWords returns the list of words to stop generation on.

func (*CallOptions) GetStreamingFunc

func (o *CallOptions) GetStreamingFunc() streaming.Callback

GetStreamingFunc returns the streaming function to use.

func (*CallOptions) GetStructuredOutput

func (o *CallOptions) GetStructuredOutput() *StructuredOutputConfig

GetStructuredOutput returns an independent copy of the structured-output configuration (or nil), so a caller cannot mutate the option's schema bytes through the returned value.

func (*CallOptions) GetTemperature

func (o *CallOptions) GetTemperature() float64

GetTemperature returns the model temperature.

func (*CallOptions) GetToolChoice

func (o *CallOptions) GetToolChoice() any

GetToolChoice returns the choice of tool to use.

func (*CallOptions) GetTools

func (o *CallOptions) GetTools() []Tool

GetTools returns the tools to use.

func (*CallOptions) GetTopK

func (o *CallOptions) GetTopK() int

GetTopK returns the number of tokens to consider for top-k sampling.

func (*CallOptions) GetTopP

func (o *CallOptions) GetTopP() float64

GetTopP returns the cumulative probability for top-p sampling.

func (*CallOptions) GetVoice

func (o *CallOptions) GetVoice() string

GetVoice returns the voice to use.

func (*CallOptions) GetWebSearchOptions

func (o *CallOptions) GetWebSearchOptions() *WebSearchOptions

GetWebSearchOptions returns the web search options.

func (*CallOptions) ValidateStructuredOutput

func (o *CallOptions) ValidateStructuredOutput() error

ValidateStructuredOutput checks the structured-output configuration for contradictions detectable without the network: a non-nil config requires JSONMode, a non-empty schema whose top-level document is a JSON object, and, when a name is set, a value acceptable to the strictest consumer (OpenAI: at most 64 chars of ASCII letters, digits, '_' or '-'). It does not verify provider-specific schema subsets — that is each adapter's job, and ultimately the API's.

type ChatMessage

type ChatMessage interface {
	// GetType gets the type of the message.
	GetType() ChatMessageType
	// GetContent gets the content of the message.
	GetContent() string
}

ChatMessage represents a message in a chat.

type ChatMessageModel

type ChatMessageModel struct {
	Type string               `bson:"type" json:"type"`
	Data ChatMessageModelData `bson:"data" json:"data"`
}

func ConvertChatMessageToModel

func ConvertChatMessageToModel(m ChatMessage) ChatMessageModel

ConvertChatMessageToModel Convert a ChatMessage to a ChatMessageModel.

func (ChatMessageModel) ToChatMessage

func (c ChatMessageModel) ToChatMessage() ChatMessage

type ChatMessageModelData

type ChatMessageModelData struct {
	Content string `bson:"content" json:"content"`
	Type    string `bson:"type"    json:"type"`
}

type ChatMessageType

type ChatMessageType string

ChatMessageType is the type of chat message.

const (
	// ChatMessageTypeAI is a message sent by an AI.
	ChatMessageTypeAI ChatMessageType = "ai"
	// ChatMessageTypeHuman is a message sent by a human.
	ChatMessageTypeHuman ChatMessageType = "human"
	// ChatMessageTypeSystem is a message sent by the system.
	ChatMessageTypeSystem ChatMessageType = "system"
	// ChatMessageTypeGeneric is a message sent by a generic user.
	ChatMessageTypeGeneric ChatMessageType = "generic"
	// ChatMessageTypeFunction is a message sent by a function.
	ChatMessageTypeFunction ChatMessageType = "function"
	// ChatMessageTypeTool is a message sent by a tool.
	ChatMessageTypeTool ChatMessageType = "tool"
)

type ContentChoice

type ContentChoice struct {
	// Content is the textual content of a response
	Content string

	// StopReason is the reason the model stopped generating output.
	StopReason string

	// GenerationInfo is arbitrary information the model adds to the response.
	GenerationInfo map[string]any

	// FuncCall is non-nil when the model asks to invoke a function/tool.
	// If a model invokes more than one function/tool, this field will only
	// contain the first one.
	FuncCall *FunctionCall

	// ToolCalls is a list of tool calls the model asks to invoke.
	ToolCalls []ToolCall

	// This field is only used with reasoning models and represents the reasoning contents of the assistant message in completion mode.
	// If the model response has tool calls, this field will be nil and the reasoning contents will be dedicated to each tool call.
	Reasoning *reasoning.ContentReasoning
}

ContentChoice is one of the response choices returned by GenerateContent calls.

type ContentPart

type ContentPart interface {
	// contains filtered or unexported methods
}

ContentPart is an interface all parts of content have to implement.

type ContentResponse

type ContentResponse struct {
	Choices []*ContentChoice
}

ContentResponse is the response returned by a GenerateContent call. It can potentially return multiple content choices.

type ErrStructuredOutputConflict

type ErrStructuredOutputConflict struct {
	Provider string
	Detail   string
}

ErrStructuredOutputConflict reports that structured output cannot be combined with another setting already present on the request (a client-level response format, message prefilling, a conflicting response MIME type, and so on).

func (*ErrStructuredOutputConflict) Error

type ErrStructuredOutputUnsupported

type ErrStructuredOutputUnsupported struct {
	Provider string
	Model    string
	Reason   string
}

ErrStructuredOutputUnsupported reports that a model or provider path is KNOWN not to accept schema-constrained output. Adapters return it only for documented gaps; an unrecognized model is passed through so the provider API is the final arbiter, never this local table.

func (*ErrStructuredOutputUnsupported) Error

type ErrStructuredOutputValidation

type ErrStructuredOutputValidation struct {
	Provider   string
	Model      string
	Choice     int
	StopReason string
	Cause      error
}

ErrStructuredOutputValidation is returned when a normal-final response is not a single JSON value valid against the requested schema. It carries the provider, model, choice index and stop reason for diagnostics and unwraps to the concrete cause; it deliberately does not embed the whole model output in its message.

func (*ErrStructuredOutputValidation) Error

func (*ErrStructuredOutputValidation) Unwrap

type Error

type Error struct {
	// Code is the standardized error code.
	Code ErrorCode

	// Message is a human-readable error message.
	Message string

	// Provider is the name of the provider that generated the error.
	Provider string

	// Details contains provider-specific error details.
	Details map[string]interface{}

	// Cause is the underlying error, if any.
	Cause error
}

Error represents a standardized error from an LLM provider.

func NewError

func NewError(code ErrorCode, provider, message string) *Error

NewError creates a new standardized error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Is

func (e *Error) Is(target error) bool

Is implements errors.Is support.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

func (*Error) WithCause

func (e *Error) WithCause(cause error) *Error

WithCause adds an underlying error cause.

func (*Error) WithDetail

func (e *Error) WithDetail(key string, value interface{}) *Error

WithDetail adds a detail to the error.

type ErrorCode

type ErrorCode string

ErrorCode represents a standardized error code for LLM operations.

const (
	// ErrCodeUnknown indicates an unknown error.
	ErrCodeUnknown ErrorCode = "unknown"

	// ErrCodeAuthentication indicates an authentication failure.
	ErrCodeAuthentication ErrorCode = "authentication"

	// ErrCodeRateLimit indicates a rate limit has been exceeded.
	ErrCodeRateLimit ErrorCode = "rate_limit"

	// ErrCodeInvalidRequest indicates the request was invalid.
	ErrCodeInvalidRequest ErrorCode = "invalid_request"

	// ErrCodeResourceNotFound indicates a requested resource was not found.
	ErrCodeResourceNotFound ErrorCode = "resource_not_found"

	// ErrCodeTimeout indicates the operation timed out.
	ErrCodeTimeout ErrorCode = "timeout"

	// ErrCodeCanceled indicates the operation was canceled.
	ErrCodeCanceled ErrorCode = "canceled"

	// ErrCodeQuotaExceeded indicates a quota has been exceeded.
	ErrCodeQuotaExceeded ErrorCode = "quota_exceeded"

	// ErrCodeContentFilter indicates content was blocked by safety filters.
	ErrCodeContentFilter ErrorCode = "content_filter"

	// ErrCodeTokenLimit indicates the token limit was exceeded.
	ErrCodeTokenLimit ErrorCode = "token_limit"

	// ErrCodeProviderUnavailable indicates the provider service is unavailable.
	ErrCodeProviderUnavailable ErrorCode = "provider_unavailable"

	// ErrCodeNotImplemented indicates a feature is not implemented.
	ErrCodeNotImplemented ErrorCode = "not_implemented"
)

type ErrorMapper

type ErrorMapper struct {
	// contains filtered or unexported fields
}

ErrorMapper helps map provider-specific errors to standardized errors.

func AnthropicErrorMapper

func AnthropicErrorMapper() *ErrorMapper

AnthropicErrorMapper creates an error mapper with Anthropic-specific patterns.

func GoogleAIErrorMapper

func GoogleAIErrorMapper() *ErrorMapper

GoogleAIErrorMapper creates an error mapper with Google AI-specific patterns.

func NewErrorMapper

func NewErrorMapper(provider string) *ErrorMapper

NewErrorMapper creates a new error mapper for a provider.

func OpenAIErrorMapper

func OpenAIErrorMapper() *ErrorMapper

OpenAIErrorMapper creates an error mapper with OpenAI-specific patterns.

func (*ErrorMapper) AddMatcher

func (m *ErrorMapper) AddMatcher(matcher ErrorMatcher) *ErrorMapper

AddMatcher adds a custom error matcher.

func (*ErrorMapper) Map

func (m *ErrorMapper) Map(err error) error

Map is an alias for WrapError for consistency with provider error mappers.

func (*ErrorMapper) WrapError

func (m *ErrorMapper) WrapError(err error) error

WrapError wraps an error with standardized error information.

type ErrorMatcher

type ErrorMatcher struct {
	// Match returns true if this matcher handles the error
	Match func(error) bool
	// Code is the error code to use
	Code ErrorCode
	// Transform optionally transforms the error message
	Transform func(error) string
}

ErrorMatcher matches an error and returns the appropriate error code.

type FunctionCall

type FunctionCall struct {
	// The name of the function to call.
	Name string `json:"name"`
	// The arguments to pass to the function, as a JSON string.
	Arguments string `json:"arguments"`
}

FunctionCall is the name and arguments of a function call.

type FunctionCallBehavior

type FunctionCallBehavior string

FunctionCallBehavior is the behavior to use when calling functions.

const (
	// FunctionCallBehaviorNone will not call any functions.
	FunctionCallBehaviorNone FunctionCallBehavior = "none"
	// FunctionCallBehaviorAuto will call functions automatically.
	FunctionCallBehaviorAuto FunctionCallBehavior = "auto"
)

type FunctionChatMessage

type FunctionChatMessage struct {
	// Name is the name of the function.
	Name string `json:"name"`
	// Content is the content of the function message.
	Content string `json:"content"`
}

FunctionChatMessage is a chat message representing the result of a function call. Deprecated: Use ToolChatMessage instead.

func (FunctionChatMessage) GetContent

func (m FunctionChatMessage) GetContent() string

func (FunctionChatMessage) GetName

func (m FunctionChatMessage) GetName() string

func (FunctionChatMessage) GetType

type FunctionDefinition

type FunctionDefinition struct {
	// Name is the name of the function.
	Name string `json:"name"`
	// Description is a description of the function.
	Description string `json:"description"`
	// Parameters is a list of parameters for the function.
	Parameters any `json:"parameters,omitempty"`
	// Strict is a flag to indicate if the function should be called strictly.
	// Provider support varies - typically used for structured output guarantees.
	Strict bool `json:"strict,omitempty"`
}

FunctionDefinition is a definition of a function that can be called by the model.

type FunctionReference

type FunctionReference struct {
	// Name is the name of the function.
	Name string `json:"name"`
}

FunctionReference is a reference to a function.

type GenericChatMessage

type GenericChatMessage struct {
	Content string
	Role    string
	Name    string
}

GenericChatMessage is a chat message with an arbitrary speaker.

func (GenericChatMessage) GetContent

func (m GenericChatMessage) GetContent() string

func (GenericChatMessage) GetName

func (m GenericChatMessage) GetName() string

func (GenericChatMessage) GetType

func (m GenericChatMessage) GetType() ChatMessageType

type HumanChatMessage

type HumanChatMessage struct {
	Content string
}

HumanChatMessage is a message sent by a human.

func (HumanChatMessage) GetContent

func (m HumanChatMessage) GetContent() string

func (HumanChatMessage) GetType

func (m HumanChatMessage) GetType() ChatMessageType

type ImageURLContent

type ImageURLContent struct {
	URL    string `json:"url"`
	Detail string `json:"detail,omitempty"` // Detail is the detail of the image, e.g. "low", "high".
}

ImageURLContent is content with an URL pointing to an image.

func ImageURLPart

func ImageURLPart(url string) ImageURLContent

ImageURLPart creates a new ImageURLContent from the given URL.

func ImageURLWithDetailPart

func ImageURLWithDetailPart(url string, detail string) ImageURLContent

ImageURLWithDetailPart creates a new ImageURLContent from the given URL and detail.

func (ImageURLContent) MarshalJSON

func (iuc ImageURLContent) MarshalJSON() ([]byte, error)

func (ImageURLContent) String

func (iuc ImageURLContent) String() string

func (*ImageURLContent) UnmarshalJSON

func (iuc *ImageURLContent) UnmarshalJSON(data []byte) error

type LLM deprecated

type LLM = Model

LLM is an alias for model, for backwards compatibility.

Deprecated: This alias may be removed in the future; please use Model instead.

type MessageContent

type MessageContent struct {
	Role  ChatMessageType
	Parts []ContentPart
}

MessageContent is the content of a message sent to a LLM. It has a role and a sequence of parts. For example, it can represent one message in a chat session sent by the user, in which case Role will be ChatMessageTypeHuman and Parts will be the sequence of items sent in this specific message.

func TextParts

func TextParts(role ChatMessageType, parts ...string) MessageContent

TextParts is a helper function to create a MessageContent with a role and a list of text parts.

func (MessageContent) MarshalJSON

func (mc MessageContent) MarshalJSON() ([]byte, error)

func (*MessageContent) UnmarshalJSON

func (mc *MessageContent) UnmarshalJSON(data []byte) error

type Model

type Model interface {
	// GenerateContent asks the model to generate content from a sequence of
	// messages. It's the most general interface for multi-modal LLMs that support
	// chat-like interactions.
	GenerateContent(ctx context.Context, messages []MessageContent, options ...CallOption) (*ContentResponse, error)

	// Call is a simplified interface for a text-only Model, generating a single
	// string response from a single string prompt.
	//
	// Deprecated: this method is retained for backwards compatibility. Use the
	// more general [GenerateContent] instead. You can also use
	// the [GenerateFromSinglePrompt] function which provides a similar capability
	// to Call and is built on top of the new interface.
	Call(ctx context.Context, prompt string, options ...CallOption) (string, error)
}

Model is an interface multi-modal models implement.

type Named

type Named interface {
	GetName() string
}

Named is an interface for objects that have a name.

type PromptValue

type PromptValue interface {
	String() string
	Messages() []ChatMessage
}

PromptValue is the interface that all prompt values must implement.

type ReasoningConfig

type ReasoningConfig struct {
	// Mode is the authoritative on/off/defer switch. When Mode is ReasoningDefault
	// (the zero value) the state is inferred from Effort/Tokens/Adaptive for
	// backward compatibility. Use WithReasoningDisabled to set ReasoningOff.
	Mode   ReasoningMode   `json:"mode,omitempty"`
	Effort ReasoningEffort `json:"effort"`
	Tokens int             `json:"tokens"`
	// Adaptive expresses a preference for adaptive thinking (thinking.type=adaptive
	// plus output_config.effort instead of a token budget). Effort sets the level;
	// Tokens is ignored. For Claude the wire mechanism is resolved from the model,
	// not this flag: an adaptive-only generation (Opus 4.7/4.8/5, Sonnet 5, Fable 5)
	// always uses adaptive and drops sampling params it rejects, a budget-only
	// generation always uses budget thinking, and this preference is honored on
	// models that support both. Providers without adaptive support fall back to
	// their effort/budget semantics.
	Adaptive bool `json:"adaptive,omitempty"`
}

ReasoningConfig is a set of options for reasoning.

func (*ReasoningConfig) GetEffort

func (r *ReasoningConfig) GetEffort(maxTokens int) ReasoningEffort

GetEffort returns enum value of the effort based on kept values inside. If maxTokens is less than 0, it will be set to 8192. If neither are set, it will return ReasoningNone. If effort is set, it will return the set effort. If tokens are set, it will return the effort that is the closest to the set tokens.

  • (0, maxTokens/4) -> ReasoningLow
  • [maxTokens/4, maxTokens/3) -> ReasoningMedium
  • [maxTokens/3, inf) -> ReasoningHigh

func (*ReasoningConfig) GetTokens

func (r *ReasoningConfig) GetTokens(maxTokens int) int

GetTokens returns the number of tokens to use for reasoning based on kept values inside. Maximum value is maxTokens*2/3 because we need to leave some tokens for the response. If maxTokens is less than 0, it will be set to 8192. If tokens are set, it will return the minimum of the set tokens and maxTokens*2/3. If effort is set, it will return the maximum of the effort and maxTokens*2/3. If neither are set, it will return 0 or -1 if effort is set to an invalid value. Minimum correct values are:

  • 1024 for ReasoningLow
  • 2048 for ReasoningMedium
  • 4096 for ReasoningHigh

func (*ReasoningConfig) IsDisabled

func (r *ReasoningConfig) IsDisabled() bool

IsDisabled reports whether reasoning is explicitly turned off (ReasoningOff), as distinct from merely unset (ReasoningDefault).

func (*ReasoningConfig) IsEnabled

func (r *ReasoningConfig) IsEnabled() bool

IsEnabled reports whether reasoning is explicitly on. It is a backward-compatible alias for ResolveMode() == ReasoningOn: true for legacy Effort/Tokens/Adaptive configs, false for an unset config, and false for an explicit ReasoningOff.

func (*ReasoningConfig) ResolveMode

func (r *ReasoningConfig) ResolveMode() ReasoningMode

ResolveMode returns the effective on/off/defer state that adapters switch on. An explicit Mode wins; otherwise (Mode == ReasoningDefault) a legacy config carrying Effort/Tokens/Adaptive resolves to ReasoningOn, and an empty config resolves to ReasoningDefault — preserving the pre-Mode behavior exactly.

type ReasoningEffort

type ReasoningEffort string
const (
	ReasoningHigh   ReasoningEffort = "high"
	ReasoningMedium ReasoningEffort = "medium"
	ReasoningLow    ReasoningEffort = "low"
	ReasoningNone   ReasoningEffort = ""
	// ReasoningXHigh and ReasoningMax are the top reasoning efforts. Anthropic models
	// carry them via WithAdaptiveReasoning (max since Claude 4.6, xhigh since Opus 4.7);
	// OpenAI-compatible providers that expose them (e.g. GPT-5.5, GLM-5.2) accept them
	// as reasoning_effort.
	ReasoningXHigh ReasoningEffort = "xhigh"
	ReasoningMax   ReasoningEffort = "max"
)

type ReasoningMode

type ReasoningMode int

ReasoningMode is the explicit on/off/defer switch for reasoning, orthogonal to how much reasoning to do (Effort/Tokens/Adaptive). It exists because models that think by default (e.g. Gemini 2.5, Claude Fable 5) cannot be turned off by simply omitting reasoning — that defers to the model default. The zero value is ReasoningDefault, so a config built only with Effort/Tokens/Adaptive (the pre-Mode API) keeps deferring/enabling exactly as before.

const (
	// ReasoningDefault omits the reasoning control and defers to the model's own
	// default. It is the zero value, so nil or legacy configs behave as before.
	ReasoningDefault ReasoningMode = iota
	// ReasoningOff explicitly disables thinking on models that support disabling
	// (adapters emit the provider's disable wire; on models that cannot be
	// disabled the adapter returns a typed error).
	ReasoningOff
	// ReasoningOn explicitly enables thinking at the configured Effort/Tokens/Adaptive.
	ReasoningOn
)

type ReasoningSupport

type ReasoningSupport struct {
	// Supported reports whether the model reasons at all.
	Supported bool
	// Known reports whether this model is explicitly classified. When false, the
	// remaining fields are best-effort and the UI should offer all controls.
	Known bool
	// CannotDisable is set only for models KNOWN to reject disabling
	// (always-on Claude such as Fable 5, and OpenAI o-series). When false,
	// disabling may still fail at the API for an unclassified model.
	CannotDisable bool
	// RejectsSampling is set for models that reject temperature/top_p while thinking.
	RejectsSampling bool
	// Efforts are the effort tiers worth offering; nil when unknown.
	Efforts []ReasoningEffort
	// DefaultOn reports whether thinking runs when reasoning is unset; nil when unknown.
	DefaultOn *bool
}

ReasoningSupport describes which reasoning controls a model accepts, as a HINT for building a UI. It is a best-effort static projection, never authoritative: an unrecognized model returns Known=false so the UI shows all controls and the provider API (an HTTP 400) is the ultimate arbiter. The table asserts only KNOWN facts; it never fabricates a capability it cannot back — unknown effort tiers and default state are left nil rather than guessed.

func ReasoningSupportFor

func ReasoningSupportFor(model string, p reasoning.Provider) ReasoningSupport

ReasoningSupportFor returns the reasoning-control hint for a model on a provider. Registered overrides win; then Claude and OpenAI reasoning models are classified from the shared tables; everything else returns Known=false (optimistic — the UI shows all controls and the API rejects what it cannot do).

type StructuredOutputConfig

type StructuredOutputConfig struct {
	Name        string          `json:"name,omitempty"`
	Description string          `json:"description,omitempty"`
	Schema      json.RawMessage `json:"schema"`
}

StructuredOutputConfig requests provider-native, schema-constrained output for a single call. Schema is the raw JSON Schema (Draft 2020-12) document, kept verbatim: the SDK never rewrites it (no injected required, additionalProperties or stripped constraints). Name identifies the schema — mandatory for OpenAI, optional for the other providers. Build it through WithStructuredOutput rather than by hand so JSONMode and the schema copy stay consistent.

func (*StructuredOutputConfig) Clone

Clone returns a deep copy whose Schema owns its bytes, so a caller mutating the original []byte after building an option cannot alter the stored configuration.

type SystemChatMessage

type SystemChatMessage struct {
	Content string
}

SystemChatMessage is a chat message representing information that should be instructions to the AI system.

func (SystemChatMessage) GetContent

func (m SystemChatMessage) GetContent() string

func (SystemChatMessage) GetType

func (m SystemChatMessage) GetType() ChatMessageType

type TextContent

type TextContent struct {
	Text      string                      `json:"text,omitempty"`
	Reasoning *reasoning.ContentReasoning `json:"reasoning,omitempty"`
}

TextContent is content with some text.

func TextPart

func TextPart(s string) TextContent

TextPart creates TextContent from a given string.

func TextPartWithReasoning

func TextPartWithReasoning(s string, reasoning *reasoning.ContentReasoning) TextContent

TextPartWithReasoning creates TextContent from a given string and reasoning content.

func (TextContent) MarshalJSON

func (tc TextContent) MarshalJSON() ([]byte, error)

func (TextContent) String

func (tc TextContent) String() string

func (*TextContent) UnmarshalJSON

func (tc *TextContent) UnmarshalJSON(data []byte) error

type Tool

type Tool struct {
	// Type is the type of the tool.
	Type string `json:"type"`
	// Function is the function to call.
	Function *FunctionDefinition `json:"function,omitempty"`
}

Tool is a tool that can be used by the model.

type ToolCall

type ToolCall struct {
	// ID is the unique identifier of the tool call.
	ID string `json:"id"`

	// Type is the type of the tool call. Typically, this would be "function".
	Type string `json:"type"`

	// FunctionCall is the function call to be executed.
	FunctionCall *FunctionCall `json:"function,omitempty"`

	// Reasoning is the reasoning content of the tool call used for Anthropic and Google AI providers.
	Reasoning *reasoning.ContentReasoning `json:"reasoning,omitempty"`
}

ToolCall is a call to a tool (as requested by the model) that should be executed.

func (ToolCall) MarshalJSON

func (tc ToolCall) MarshalJSON() ([]byte, error)

func (*ToolCall) UnmarshalJSON

func (tc *ToolCall) UnmarshalJSON(data []byte) error

type ToolCallResponse

type ToolCallResponse struct {
	// ToolCallID is the ID of the tool call this response is for.
	ToolCallID string `json:"tool_call_id"`

	// Name is the name of the tool that was called.
	Name string `json:"name"`

	// Content is the textual content of the response.
	Content string `json:"content"`
}

ToolCallResponse is the response returned by a tool call.

func (ToolCallResponse) MarshalJSON

func (tc ToolCallResponse) MarshalJSON() ([]byte, error)

func (*ToolCallResponse) UnmarshalJSON

func (tc *ToolCallResponse) UnmarshalJSON(data []byte) error

type ToolChatMessage

type ToolChatMessage struct {
	// ID is the ID of the tool call.
	ID string `json:"tool_call_id,omitempty"`
	// Name is the name of the tool.
	Name string `json:"tool_name,omitempty"`
	// Content is the content of the tool message.
	Content string `json:"content"`
}

ToolChatMessage is a chat message representing the result of a tool call.

func (ToolChatMessage) GetContent

func (m ToolChatMessage) GetContent() string

func (ToolChatMessage) GetID

func (m ToolChatMessage) GetID() string

func (ToolChatMessage) GetName

func (m ToolChatMessage) GetName() string

func (ToolChatMessage) GetType

func (m ToolChatMessage) GetType() ChatMessageType

type ToolChoice

type ToolChoice struct {
	// Type is the type of the tool.
	Type string `json:"type"`
	// Function is the function to call (if the tool is a function).
	Function *FunctionReference `json:"function,omitempty"`
}

ToolChoice is a specific tool to use.

type UserLocation

type UserLocation struct {
	// Type must be "approximate" for user-provided location.
	Type string `json:"type"`

	// Approximate contains the approximate location details.
	Approximate *ApproximateLocation `json:"approximate,omitempty"`
}

UserLocation represents the user's approximate location for web search.

type WebSearchOptions

type WebSearchOptions struct {
	// SearchContextSize controls how much context is gathered from web search.
	// Valid values: "low", "medium", "high". Higher values provide more context
	// but increase latency and cost.
	SearchContextSize string `json:"search_context_size,omitempty"`

	// UserLocation provides approximate user location for localized search results.
	UserLocation *UserLocation `json:"user_location,omitempty"`
}

WebSearchOptions configures web search behavior for models that support web search. This is currently supported by OpenAI models like gpt-4o-search-preview.

Directories

Path Synopsis
Package bedrock provides AWS Bedrock integration for LangChainGo.
Package bedrock provides AWS Bedrock integration for LangChainGo.
Package cache provides a generic wrapper that adds caching to a `llms.Model`.
Package cache provides a generic wrapper that adds caching to a `llms.Model`.
Package googleai provides caching support for Google AI models.
Package googleai provides caching support for Google AI models.
internal/cmd command
Obsolete generator: the vertex package is now hand-maintained.
Obsolete generator: the vertex package is now hand-maintained.
palm
package palm implements a langchaingo provider for Google Vertex AI legacy PaLM models.
package palm implements a langchaingo provider for Google Vertex AI legacy PaLM models.
vertex
package vertex implements a langchaingo provider for Google Vertex AI LLMs, including the new Gemini models.
package vertex implements a langchaingo provider for Google Vertex AI LLMs, including the new Gemini models.
Package openai provides an interface to OpenAI's language models.
Package openai provides an interface to OpenAI's language models.
Package reasoning provides primitives for working with reasoning content.
Package reasoning provides primitives for working with reasoning content.
Package streaming provides a streaming interface for LLMs.
Package streaming provides a streaming interface for LLMs.
Package structuredoutput compiles a JSON Schema and validates a model's final text response against it, backing the provider-neutral llms.WithStructuredOutput contract.
Package structuredoutput compiles a JSON Schema and validates a model's final text response against it, backing the provider-neutral llms.WithStructuredOutput contract.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL