Documentation
¶
Index ¶
- Constants
- Variables
- func AudioMimeFromBytes(data []byte) (mime string, ok bool)
- func CanonicalBackendType(backendType string) string
- func ChatDialectNames() []string
- func ClampMaxOutputTokens(requested, ceiling int) (int, bool)
- func ClampMaxOutputTokensPtr(tokens *int, ceiling int) *int
- func ClassifyProviderError(err error, httpStatus int, code, message string) error
- func DoWithRetry(ctx context.Context, client *http.Client, build func() (*http.Request, error)) (*http.Response, error)
- func GeminiModelSupportsAudio(modelName string) bool
- func GeminiModelSupportsVision(modelName string) bool
- func HasCatalogProvider(backendType string) bool
- func IsBackendTerminal(err error) bool
- func IsContextLimitMessage(s string) bool
- func IsLocalBackendType(backendType string) bool
- func IsRetryableStreamFailure(err error) bool
- func IsWAV(data []byte) bool
- func MessagesAudioBytes(messages []Message) (parts int, totalBytes int)
- func MessagesHaveAudio(messages []Message) bool
- func MessagesHaveImages(messages []Message) bool
- func MessagesImageCount(messages []Message) int
- func ModelID(name string) string
- func NonStreamingContext(ctx context.Context) (context.Context, context.CancelFunc)
- func OpenAIModelSupportsVision(modelName string) bool
- func ProviderErrorDetail(body []byte) (code, message string)
- func RefuseAudioInput(providerType, modelName string, messages []Message) error
- func RegisterCatalogProvider(backendType string, constructor CatalogProviderConstructor)
- func RegisterChatDialect(dialect ChatDialect)
- func RegisterShutdownHook(fn func() error)
- func RegisterThinkDeclarationRefusal(backendType, reason string)
- func RequestedContextLengthFromContext(ctx context.Context) int
- func RetryAfterDelay(h http.Header, fallback time.Duration) time.Duration
- func RewriteChatBody(dialect ChatDialect, body []byte, req DialectRequest) ([]byte, error)
- func SameModel(a, b string) bool
- func SetupVLLMLocalInstance(ctx context.Context, model string, tag string, toolParser string) (string, testcontainers.Container, func(), error)
- func Shutdown() error
- func SupportedAudioMimeList() string
- func ThinkDeclarationRefusal(backendType string) (reason string, ok bool)
- func ValidateAudioBytes(providerType, modelName string, messages []Message) error
- func ValidateAudioParts(providerType, modelName string, messages []Message) error
- func WithEmbeddingPurpose(ctx context.Context, purpose EmbeddingPurpose) context.Context
- func WithRequestedContextLength(ctx context.Context, contextLength int) context.Context
- func WithoutRequestedContextLength(ctx context.Context) context.Context
- type AudioPart
- type AutocompleteRequest
- type AutocompleteResult
- type BackendSpec
- type CacheHints
- type CachePolicyCatalog
- type CapabilityConfig
- type CatalogFactory
- type CatalogOption
- type CatalogOptions
- type CatalogProvider
- type CatalogProviderConstructor
- type ChatArgument
- func WithCacheHints(hints CacheHints) ChatArgument
- func WithMaxTokens(tokens int) ChatArgument
- func WithParallelToolCalls(enabled bool) ChatArgument
- func WithResponseFormat(format ResponseFormat) ChatArgument
- func WithSeed(seed int) ChatArgument
- func WithStopSequences(sequences ...string) ChatArgument
- func WithTemperature(temp float64) ChatArgument
- func WithTool(tool Tool) ChatArgument
- func WithToolChoice(choice ToolChoice) ChatArgument
- func WithTools(tools ...Tool) ChatArgument
- func WithTopP(p float64) ChatArgument
- type ChatConfig
- type ChatDialect
- type ChatResult
- type Continuation
- type DialectRequest
- type EmbeddingPurpose
- type FunctionTool
- type HTTPError
- type ImagePart
- type LLMAutocompleteClient
- type LLMChatClient
- type LLMEmbedClient
- type LLMNextEditClient
- type LLMPromptExecClient
- type LLMStreamClient
- type Message
- type MockChatClient
- type MockEmbedClient
- type MockPromptClient
- type MockProvider
- func (m *MockProvider) CanAudio() bool
- func (m *MockProvider) CanAutocomplete() bool
- func (m *MockProvider) CanChat() bool
- func (m *MockProvider) CanEmbed() bool
- func (m *MockProvider) CanNextEdit() bool
- func (m *MockProvider) CanPrompt() bool
- func (m *MockProvider) CanStream() bool
- func (m *MockProvider) CanThink() bool
- func (m *MockProvider) CanVision() bool
- func (m *MockProvider) GetAutocompleteConnection(context.Context, string) (LLMAutocompleteClient, error)
- func (m *MockProvider) GetBackendIDs() []string
- func (m *MockProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
- func (m *MockProvider) GetContextLength() int
- func (m *MockProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
- func (m *MockProvider) GetID() string
- func (m *MockProvider) GetMaxOutputTokens() int
- func (m *MockProvider) GetNextEditConnection(context.Context, string) (LLMNextEditClient, error)
- func (m *MockProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
- func (m *MockProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
- func (m *MockProvider) GetType() string
- func (m *MockProvider) ModelName() string
- type MockStreamClient
- type ModelCachePolicy
- type NextEditRequest
- type NextEditResult
- type ObservedModel
- type PromptArgument
- type PromptCacheContract
- type PromptConfig
- type Provider
- type ProviderError
- type RefusalError
- type ResponseFormat
- type ResponseFormatMode
- type StreamAssembler
- type StreamParcel
- type StreamResult
- type StreamTerminal
- type ThinkingTypes
- type TokenUsage
- type Tool
- type ToolCall
- type ToolCallDelta
- type ToolChoice
- type ToolChoiceMode
- type UnsupportedDialectLevelError
- type WireMessage
- type WithPromptMaxTokens
- type WithShift
- type WithThink
Constants ¶
View Source
const ( PromptCacheFieldTools = "tools" PromptCacheFieldSystem = "system" PromptCacheFieldMessages = "messages" )
View Source
const ( PromptCacheTTLFiveMinutes = "5m" PromptCacheTTLOneHour = "1h" )
View Source
const DefaultCallTimeout = 10 * time.Minute
View Source
const MaxInlineAudioBytes = 14 << 20
View Source
const MaxStopSequences = 4
View Source
const ModelResourcePrefix = "models/"
View Source
const ObservedDisplayNameMetaKey = "display_name"
View Source
const ObservedFunctionCallingMetaKey = "function_calling"
View Source
const ScriptedTestBackendType = "scripted-test"
View Source
const ToolResultErrorKey = "tool_result_is_error"
View Source
const WAVMimeType = "audio/wav"
Variables ¶
View Source
var ( ErrAudioNotSupported = errors.New("model cannot accept audio input") ErrUnsupportedAudioMime = errors.New("unsupported audio media type") ErrAudioTooLarge = errors.New("inline audio exceeds the request size limit") )
View Source
var ( ErrContextLengthExceeded = errors.New("request exceeds the model's context window") ErrRateLimited = errors.New("provider rate limit or capacity limit hit") ErrModelNotFoundOnBackend = errors.New("backend does not serve the requested model") ErrModelAccessDenied = errors.New("backend denied access to the requested model") ErrPaymentRequired = errors.New("provider account requires payment") ErrRequestTooLarge = errors.New("request exceeds the provider's size limit") )
View Source
var ErrAutocompleteUnsupported = errors.New("native autocomplete is unavailable; select a FIM-capable connection and model or explicitly configure instructed completion")
View Source
var ErrNextEditUnsupported = errors.New("independent next edit prediction is unavailable for the selected model")
View Source
var ErrNoDialog = errors.New("no dialog behind this provider")
View Source
var ErrNotSupported = errors.New("operation not supported")
View Source
var ErrRefused = errors.New("model refused the request")
View Source
var ErrStreamTruncated = errors.New("stream ended before the provider's terminal marker")
View Source
var ErrUnknownChatDialect = errors.New("unknown chat dialect")
Functions ¶
func AudioMimeFromBytes ¶
func CanonicalBackendType ¶ added in v0.32.0
func ChatDialectNames ¶
func ChatDialectNames() []string
func ClampMaxOutputTokens ¶ added in v0.29.0
func ClampMaxOutputTokensPtr ¶ added in v0.29.0
func ClassifyProviderError ¶
func DoWithRetry ¶
func HasCatalogProvider ¶
func IsBackendTerminal ¶
func IsContextLimitMessage ¶
func IsLocalBackendType ¶ added in v0.32.6
func MessagesAudioBytes ¶
func MessagesHaveAudio ¶
func MessagesHaveImages ¶
func MessagesImageCount ¶
func NonStreamingContext ¶
func ProviderErrorDetail ¶
func RefuseAudioInput ¶
func RegisterCatalogProvider ¶
func RegisterCatalogProvider(backendType string, constructor CatalogProviderConstructor)
func RegisterChatDialect ¶
func RegisterChatDialect(dialect ChatDialect)
func RegisterShutdownHook ¶ added in v0.32.0
func RegisterShutdownHook(fn func() error)
func RegisterThinkDeclarationRefusal ¶
func RegisterThinkDeclarationRefusal(backendType, reason string)
func RequestedContextLengthFromContext ¶ added in v0.33.0
func RewriteChatBody ¶
func RewriteChatBody(dialect ChatDialect, body []byte, req DialectRequest) ([]byte, error)
func SetupVLLMLocalInstance ¶
func SupportedAudioMimeList ¶
func SupportedAudioMimeList() string
func ThinkDeclarationRefusal ¶
func ValidateAudioBytes ¶
func ValidateAudioParts ¶
func WithEmbeddingPurpose ¶
func WithEmbeddingPurpose(ctx context.Context, purpose EmbeddingPurpose) context.Context
func WithRequestedContextLength ¶ added in v0.33.0
Types ¶
type AutocompleteRequest ¶
type AutocompleteRequest struct {
Prefix string
Suffix string
MaxTokens int
Temperature float64
TopP float64
Seed int
SessionKey string
StopSequences []string
MinTokens int
}
func (AutocompleteRequest) Validate ¶
func (r AutocompleteRequest) Validate() error
type AutocompleteResult ¶
type AutocompleteResult struct {
Text string
FinishReason string
Usage *TokenUsage
}
type BackendSpec ¶
type CacheHints ¶
type CachePolicyCatalog ¶
type CachePolicyCatalog interface {
CachePolicy() ModelCachePolicy
}
type CapabilityConfig ¶
type CapabilityConfig struct {
CompletionMode string
FIMFormat string
CanAutocomplete bool
NextEditFormat string
CanNextEdit bool
ContextLength int
MaxOutputTokens int
CanChat bool
CanEmbed bool
CanStream bool
CanPrompt bool
CanThink bool
CanVision bool
CanAudio bool
AudioExtension bool
SessionExtension bool
ThinkingTypes *ThinkingTypes
Dialect string
PromptCache *PromptCacheContract
}
type CatalogFactory ¶
type CatalogFactory interface {
NewCatalogProvider(spec BackendSpec, opts ...CatalogOption) (CatalogProvider, error)
}
func DefaultCatalogFactory ¶
func DefaultCatalogFactory() CatalogFactory
type CatalogOption ¶
type CatalogOption func(*CatalogOptions)
func WithCatalogAuthorizer ¶
func WithCatalogHTTPClient ¶
func WithCatalogHTTPClient(client *http.Client) CatalogOption
func WithCatalogTracker ¶
func WithCatalogTracker(tracker libtracker.ActivityTracker) CatalogOption
type CatalogOptions ¶
type CatalogOptions struct {
Authorize func(context.Context) (http.Header, error)
HTTPClient *http.Client
Tracker libtracker.ActivityTracker
}
type CatalogProvider ¶
type CatalogProvider interface {
Type() string
ListModels(ctx context.Context) ([]ObservedModel, error)
ProviderFor(model ObservedModel) Provider
}
func NewCatalogProvider ¶
func NewCatalogProvider(spec BackendSpec, opts ...CatalogOption) (CatalogProvider, error)
type CatalogProviderConstructor ¶
type CatalogProviderConstructor func(spec BackendSpec, opts CatalogOptions) (CatalogProvider, error)
type ChatArgument ¶
type ChatArgument interface {
Apply(config *ChatConfig)
}
func WithCacheHints ¶
func WithCacheHints(hints CacheHints) ChatArgument
func WithMaxTokens ¶
func WithMaxTokens(tokens int) ChatArgument
func WithParallelToolCalls ¶
func WithParallelToolCalls(enabled bool) ChatArgument
func WithResponseFormat ¶
func WithResponseFormat(format ResponseFormat) ChatArgument
func WithSeed ¶
func WithSeed(seed int) ChatArgument
func WithStopSequences ¶
func WithStopSequences(sequences ...string) ChatArgument
func WithTemperature ¶
func WithTemperature(temp float64) ChatArgument
func WithTool ¶
func WithTool(tool Tool) ChatArgument
func WithToolChoice ¶
func WithToolChoice(choice ToolChoice) ChatArgument
func WithTools ¶
func WithTools(tools ...Tool) ChatArgument
func WithTopP ¶
func WithTopP(p float64) ChatArgument
type ChatConfig ¶
type ChatConfig struct {
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Seed *int `json:"seed,omitempty"`
Tools []Tool `json:"tools,omitempty"`
Think *string `json:"think,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
ToolChoice *ToolChoice `json:"tool_choice,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
Format *ResponseFormat `json:"response_format,omitempty"`
Shift *bool `json:"shift,omitempty"`
Truncate *bool `json:"truncate,omitempty"`
CacheHints *CacheHints `json:"-"`
}
func (*ChatConfig) Validate ¶
func (c *ChatConfig) Validate() error
type ChatDialect ¶
type ChatDialect interface {
Name() string
DocURL() string
RewriteBody(body map[string]any, req DialectRequest) error
OwnsReasoning() bool
ThinkingMember(req DialectRequest) string
WireAssistantMessage(content, thinking string) (WireMessage, error)
}
func ChatDialectFor ¶
func ChatDialectFor(name string) (ChatDialect, error)
func MustChatDialectFor ¶
func MustChatDialectFor(name string) ChatDialect
type ChatResult ¶
type ChatResult struct {
Message Message
ToolCalls []ToolCall
Usage *TokenUsage
FinishReason string
Refusal string
}
type Continuation ¶
type Continuation struct {
Provider string `json:"provider"`
Model string `json:"model"`
Items json.RawMessage `json:"items"`
}
type DialectRequest ¶
type DialectRequest struct {
Think *string
Tools bool
CacheHints *CacheHints
Thinking *ThinkingTypes
}
func (DialectRequest) AllowsEffort ¶
func (r DialectRequest) AllowsEffort(wire string) bool
func (DialectRequest) ThinkLevel ¶
func (r DialectRequest) ThinkLevel() (string, error)
type EmbeddingPurpose ¶
type EmbeddingPurpose string
const ( EmbeddingDocument EmbeddingPurpose = "document" EmbeddingQuery EmbeddingPurpose = "query" )
func EmbeddingPurposeFromContext ¶
func EmbeddingPurposeFromContext(ctx context.Context) EmbeddingPurpose
type FunctionTool ¶
type LLMAutocompleteClient ¶
type LLMAutocompleteClient interface {
Autocomplete(context.Context, AutocompleteRequest) (AutocompleteResult, error)
}
type LLMChatClient ¶
type LLMChatClient interface {
Chat(ctx context.Context, messages []Message, args ...ChatArgument) (ChatResult, error)
}
type LLMEmbedClient ¶
type LLMNextEditClient ¶
type LLMNextEditClient interface {
NextEdit(context.Context, NextEditRequest) (NextEditResult, error)
}
type LLMPromptExecClient ¶
type LLMPromptExecClient interface {
Prompt(ctx context.Context, systemInstruction string, temperature float32, prompt string, args ...PromptArgument) (string, *TokenUsage, error)
}
type LLMStreamClient ¶
type LLMStreamClient interface {
Stream(ctx context.Context, messages []Message, args ...ChatArgument) (<-chan *StreamParcel, error)
}
type Message ¶
type Message struct {
Continuation *Continuation `json:"continuation,omitempty"`
Role string `json:"role"`
Content string `json:"content"`
Images []ImagePart `json:"images,omitempty"`
Audio []AudioPart `json:"audio,omitempty"`
Thinking string `json:"thinking,omitempty"`
Refusal string `json:"refusal,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolResultError bool `json:"tool_result_error,omitempty"`
}
type MockChatClient ¶
type MockChatClient struct {
// contains filtered or unexported fields
}
func (*MockChatClient) Chat ¶
func (m *MockChatClient) Chat(ctx context.Context, messages []Message, opts ...ChatArgument) (ChatResult, error)
func (*MockChatClient) Close ¶
func (m *MockChatClient) Close() error
type MockEmbedClient ¶
type MockEmbedClient struct {
// contains filtered or unexported fields
}
func (*MockEmbedClient) Close ¶
func (m *MockEmbedClient) Close() error
type MockPromptClient ¶
type MockPromptClient struct {
// contains filtered or unexported fields
}
func (*MockPromptClient) Close ¶
func (m *MockPromptClient) Close() error
func (*MockPromptClient) Prompt ¶
func (m *MockPromptClient) Prompt(ctx context.Context, systemInstruction string, temperature float32, prompt string, args ...PromptArgument) (string, *TokenUsage, error)
type MockProvider ¶
type MockProvider struct {
ID string
Name string
ContextLength int
MaxOutputTokens int
CanChatFlag bool
CanEmbedFlag bool
CanStreamFlag bool
CanPromptFlag bool
CanAutocompleteFlag bool
CanNextEditFlag bool
CanVisionFlag bool
CanAudioFlag bool
Backends []string
}
func (*MockProvider) CanAudio ¶
func (m *MockProvider) CanAudio() bool
func (*MockProvider) CanAutocomplete ¶
func (m *MockProvider) CanAutocomplete() bool
func (*MockProvider) CanChat ¶
func (m *MockProvider) CanChat() bool
func (*MockProvider) CanEmbed ¶
func (m *MockProvider) CanEmbed() bool
func (*MockProvider) CanNextEdit ¶
func (m *MockProvider) CanNextEdit() bool
func (*MockProvider) CanPrompt ¶
func (m *MockProvider) CanPrompt() bool
func (*MockProvider) CanStream ¶
func (m *MockProvider) CanStream() bool
func (*MockProvider) CanThink ¶
func (m *MockProvider) CanThink() bool
func (*MockProvider) CanVision ¶
func (m *MockProvider) CanVision() bool
func (*MockProvider) GetAutocompleteConnection ¶
func (m *MockProvider) GetAutocompleteConnection(context.Context, string) (LLMAutocompleteClient, error)
func (*MockProvider) GetBackendIDs ¶
func (m *MockProvider) GetBackendIDs() []string
func (*MockProvider) GetChatConnection ¶
func (m *MockProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
func (*MockProvider) GetContextLength ¶
func (m *MockProvider) GetContextLength() int
func (*MockProvider) GetEmbedConnection ¶
func (m *MockProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
func (*MockProvider) GetID ¶
func (m *MockProvider) GetID() string
func (*MockProvider) GetMaxOutputTokens ¶ added in v0.29.0
func (m *MockProvider) GetMaxOutputTokens() int
func (*MockProvider) GetNextEditConnection ¶
func (m *MockProvider) GetNextEditConnection(context.Context, string) (LLMNextEditClient, error)
func (*MockProvider) GetPromptConnection ¶
func (m *MockProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
func (*MockProvider) GetStreamConnection ¶
func (m *MockProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
func (*MockProvider) GetType ¶
func (m *MockProvider) GetType() string
func (*MockProvider) ModelName ¶
func (m *MockProvider) ModelName() string
type MockStreamClient ¶
type MockStreamClient struct {
// contains filtered or unexported fields
}
func (*MockStreamClient) Close ¶
func (m *MockStreamClient) Close() error
func (*MockStreamClient) Stream ¶
func (m *MockStreamClient) Stream(ctx context.Context, messages []Message, args ...ChatArgument) (<-chan *StreamParcel, error)
type ModelCachePolicy ¶
type NextEditRequest ¶
type NextEditRequest struct {
Input modelcontract.NextEditInput
MaxTokens int
Temperature float64
TopP float64
Seed int
SessionKey string
}
func (NextEditRequest) Validate ¶
func (r NextEditRequest) Validate() error
type NextEditResult ¶
type NextEditResult struct {
Edits []modelcontract.TextEdit
FinishReason string
Usage *TokenUsage
}
type ObservedModel ¶
type PromptArgument ¶
type PromptArgument interface {
Apply(*PromptConfig)
}
type PromptCacheContract ¶
type PromptCacheContract struct {
Fields []string `json:"fields,omitempty"`
TTLs []string `json:"ttls,omitempty"`
}
func (*PromptCacheContract) SupportsField ¶
func (c *PromptCacheContract) SupportsField(field string) bool
func (*PromptCacheContract) SupportsTTL ¶
func (c *PromptCacheContract) SupportsTTL(ttl string) bool
type PromptConfig ¶
type PromptConfig struct {
MaxTokens *int
}
func PromptConfigFromArgs ¶
func PromptConfigFromArgs(args ...PromptArgument) (*PromptConfig, error)
type Provider ¶
type Provider interface {
GetBackendIDs() []string
ModelName() string
GetID() string
GetType() string
GetContextLength() int
GetMaxOutputTokens() int
CanChat() bool
CanEmbed() bool
CanStream() bool
CanPrompt() bool
CanAutocomplete() bool
CanNextEdit() bool
CanThink() bool
CanVision() bool
CanAudio() bool
GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
GetAutocompleteConnection(ctx context.Context, backendID string) (LLMAutocompleteClient, error)
GetNextEditConnection(ctx context.Context, backendID string) (LLMNextEditClient, error)
GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
}
type ProviderError ¶
type ProviderError struct {
StatusCode int
Code string
Message string
RequestID string
// contains filtered or unexported fields
}
func (*ProviderError) Error ¶
func (e *ProviderError) Error() string
func (*ProviderError) Unwrap ¶
func (e *ProviderError) Unwrap() error
type RefusalError ¶
func (*RefusalError) Error ¶
func (e *RefusalError) Error() string
func (*RefusalError) Unwrap ¶
func (e *RefusalError) Unwrap() error
type ResponseFormat ¶
type ResponseFormat struct {
Mode ResponseFormatMode
Name string
Schema any
Strict bool
}
func (ResponseFormat) Validate ¶
func (f ResponseFormat) Validate() error
type ResponseFormatMode ¶
type ResponseFormatMode string
const ( ResponseFormatText ResponseFormatMode = "text" ResponseFormatJSONObject ResponseFormatMode = "json_object" ResponseFormatJSONSchema ResponseFormatMode = "json_schema" )
type StreamAssembler ¶
type StreamAssembler struct {
// contains filtered or unexported fields
}
func NewStreamAssembler ¶
func NewStreamAssembler(providerType, modelName string) *StreamAssembler
func (*StreamAssembler) Consume ¶
func (a *StreamAssembler) Consume(p *StreamParcel) error
func (*StreamAssembler) Result ¶
func (a *StreamAssembler) Result() (StreamResult, error)
type StreamParcel ¶
type StreamParcel struct {
Data string
Thinking string
ToolCall *ToolCallDelta
Usage *TokenUsage
Terminal *StreamTerminal
Error error
}
type StreamResult ¶
type StreamResult struct {
Continuation *Continuation
Content string
Thinking string
ToolCalls []ToolCall
FinishReason string
Refusal string
StopSequence string
Usage *TokenUsage
}
type StreamTerminal ¶
type StreamTerminal struct {
Continuation *Continuation
FinishReason string
Usage *TokenUsage
Refusal string
StopSequence string
Terminated bool
}
type ThinkingTypes ¶
type ThinkingTypes struct {
Adaptive bool `json:"adaptive"`
Enabled bool `json:"enabled"`
Disabled bool `json:"disabled"`
EffortLevels []string `json:"effortLevels,omitempty"`
}
func (*ThinkingTypes) Controls ¶
func (t *ThinkingTypes) Controls() bool
func (*ThinkingTypes) SupportsEffort ¶
func (t *ThinkingTypes) SupportsEffort(level string) bool
func (*ThinkingTypes) Validate ¶
func (t *ThinkingTypes) Validate() error
type TokenUsage ¶
type TokenUsage struct {
PromptTokens int
CompletionTokens int
ThinkingTokens int
TotalTokens int
CacheReadTokens int
CacheWriteTokens int
}
func (*TokenUsage) Merge ¶
func (u *TokenUsage) Merge(src *TokenUsage)
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function *FunctionTool `json:"function,omitempty"`
}
type ToolCallDelta ¶
type ToolChoice ¶
type ToolChoice struct {
Mode ToolChoiceMode
Tool string
}
func (ToolChoice) Validate ¶
func (t ToolChoice) Validate() error
type ToolChoiceMode ¶
type ToolChoiceMode string
const ( ToolChoiceAuto ToolChoiceMode = "auto" ToolChoiceNone ToolChoiceMode = "none" ToolChoiceRequired ToolChoiceMode = "required" )
type UnsupportedDialectLevelError ¶
func (*UnsupportedDialectLevelError) Error ¶
func (e *UnsupportedDialectLevelError) Error() string
type WireMessage ¶
type WithPromptMaxTokens ¶
type WithPromptMaxTokens int
func (WithPromptMaxTokens) Apply ¶
func (w WithPromptMaxTokens) Apply(config *PromptConfig)
Source Files
¶
- audio.go
- audiogoogle.go
- autocomplete.go
- backendtype.go
- cachepolicy.go
- catalogfacts.go
- catalogprovider.go
- chatdialect.go
- doc.go
- embedding_context.go
- errors.go
- httpclient.go
- localbackend.go
- mockmodelprovider.go
- modelid.go
- modelprovider.go
- modelproviderarguments.go
- modelprovidertypes.go
- nextedit.go
- request_context.go
- shutdown.go
- streamassembly.go
- thinkdeclaration.go
- tokens.go
- visiongoogle.go
- visionopenai.go
- vllmtestcontainer.go
Click to show internal directories.
Click to hide internal directories.