Documentation
¶
Index ¶
- Constants
- func AppendAssistantMessageDiagnostic(message *Message, diagnostic AssistantMessageDiagnostic)
- func ApplyOpenAIAnthropicCacheControl(messages []OpenAIChatMessage, tools []OpenAIChatTool, ...)
- func ApplyOpenAICodexServiceTierPricing(usage *Usage, serviceTier string, model Model)
- func ApplyOpenAIResponsesServiceTierPricing(usage *Usage, serviceTier string, model Model)
- func BuildAnthropicHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string
- func BuildAnthropicRequestHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string
- func BuildBedrockAdditionalModelRequestFields(model Model, options BedrockPayloadOptions) map[string]any
- func BuildCopilotDynamicHeaders(messages []Message) map[string]string
- func BuildDefaultAzureOpenAIBaseURL(resourceName string) string
- func BuildOpenAICodexSSEHeaders(modelHeaders, optionHeaders map[string]string, token, sessionID string) (map[string]string, error)
- func BuildOpenAICodexWebSocketHeaders(modelHeaders, optionHeaders map[string]string, token, requestID string) (map[string]string, error)
- func BuildOpenAICompletionsHeaders(model Model, options OpenAICompletionsPayloadOptions) map[string]string
- func BuildOpenAIResponsesHeaders(model Model, options OpenAIResponsesPayloadOptions) map[string]string
- func ClampThinkingLevel(model Model, level string) string
- func CleanupSessionResources(sessionID string) error
- func ClearAPIProviders()
- func CloseOpenAICodexWebSocketSessions(sessionIDs ...string)
- func ExtractOpenAICodexAccountID(token string) (string, error)
- func FindEnvKeys(provider string) []string
- func FormatThrownValue(value any) string
- func FromClaudeCodeToolName(name string, tools []Tool) string
- func GetConfiguredBedrockRegion(options BedrockClientOptions) string
- func GetEnvAPIKey(provider string) string
- func GetImageProviders() []string
- func GetOverflowPatterns() []*regexp.Regexp
- func GetProviders() []string
- func GetSupportedThinkingLevels(model Model) []string
- func GitHubCopilotBaseURL(token, enterpriseDomain string) string
- func GitHubCopilotPollSchedule(startMillis int64, intervalSeconds, expiresSeconds int, ...) ([]int64, error)
- func GoogleThinkingBudget(model Model, effort string, custom map[string]int) int
- func GoogleThinkingLevel(effort string, model Model) string
- func GoogleVertexBaseURLIncludesAPIVersion(baseURL string) bool
- func HasConfiguredBedrockProfile(options BedrockClientOptions) bool
- func HasCopilotVisionInput(messages []Message) bool
- func InferCopilotInitiator(messages []Message) string
- func IsAnthropicClaudeBedrockModel(model Model) bool
- func IsCloudflareProvider(provider string) bool
- func IsContextOverflow(message Message, contextWindow int) bool
- func IsGoogleThinkingPart(part GooglePart) bool
- func IsGovCloudBedrockTarget(model Model, options BedrockPayloadOptions) bool
- func IsMalformedJSONError(err error) bool
- func IsOpenAICodexRetryable(status int, body string) bool
- func IsPlaceholderAPIKey(apiKey string) bool
- func IsSessionResourceCleanupError(err error) bool
- func MapAnthropicThinkingEffort(model Model, level string) string
- func MapBedrockThinkingEffort(model Model, level string) string
- func MapGoogleFinishReason(reason string) string
- func MapMistralReasoningEffort(model Model, level string) string
- func MapOpenAIChatFinishReason(reason string) (string, string)
- func ModelsAreEqual(a, b *Model) bool
- func NormalizeAzureOpenAIBaseURL(baseURL string) (string, error)
- func NormalizeToolCallIDForAnthropic(id string) string
- func NormalizeToolCallIDForOpenAICompletions(id string, model Model) string
- func NormalizeToolCallIDForOpenAIResponses(id string, target Model, source Message, ...) string
- func NowMillis() int64
- func OAuthErrorHTML(message, details string) string
- func OAuthPageHTML(options OAuthPageOptions) string
- func OAuthSuccessHTML(message string) string
- func OpenAICodexRefreshError(status int, statusText, body string) error
- func OpenAICodexRetryDelay(status int, headers map[string]string, attempt int, now time.Time) time.Duration
- func OpenAICodexServiceTierCostMultiplier(model Model, serviceTier string) float64
- func OpenAIResponsesServiceTierCostMultiplier(model Model, serviceTier string) float64
- func RegisterAPIProvider(api string, provider APIProvider)
- func RegisterAPIProviderWithSource(api string, provider APIProvider, sourceID string)
- func RegisterBuiltInAPIProvider(api string, provider APIProvider)
- func RegisterBuiltInAPIProviders()
- func RegisterImageModel(model ImagesModel)
- func RegisterImagesAPIProvider(api string, provider ImagesAPIProvider)
- func RegisterModel(model Model)
- func RegisterSessionResourceCleanup(cleanup SessionResourceCleanup) func()
- func RepairJSON(data string) string
- func RequiresGoogleToolCallID(modelID string) bool
- func ResetAPIProviders()
- func ResetOpenAICodexWebSocketDebugStats(sessionIDs ...string)
- func ResolveAzureDeploymentName(model Model, explicit string) string
- func ResolveCloudflareBaseURL(model Model) (string, error)
- func ResolveGoogleVertexAPIKey(options GoogleVertexOptions) string
- func ResolveGoogleVertexCustomBaseURL(baseURL string) string
- func ResolveHTTPProxyURLForTarget(targetURL string) (*url.URL, error)
- func ResolveOpenAICodexServiceTier(responseServiceTier, requestServiceTier string) string
- func ResolveOpenAICodexURL(baseURL string) string
- func ResolveOpenAICodexWebSocketURL(baseURL string) string
- func RetainGoogleThoughtSignature(existing, incoming string) string
- func SanitizeSchemaForOpenAPI(schema any) any
- func SanitizeSurrogates(text string) string
- func SchemaToMap(schema Schema) map[string]any
- func ShouldSendOpenAICompletionsTools(context Context) bool
- func ShouldUseExplicitBedrockEndpoint(baseURL, configuredRegion string, hasConfiguredProfile bool) bool
- func StandardBedrockEndpointRegion(baseURL string) string
- func SupportsAnthropicAdaptiveThinking(model Model) bool
- func SupportsBedrockAdaptiveThinking(model Model) bool
- func SupportsBedrockPromptCaching(model Model, force bool) bool
- func SupportsGoogleMultimodalFunctionResponse(modelID string) bool
- func ToClaudeCodeToolName(name string) string
- func UUIDLikeID() string
- func UnmarshalJSONWithRepair(data []byte, target any) error
- func UnregisterAPIProvider(api string)
- func UnregisterAPIProviders(sourceID string)
- func UnregisterImagesAPIProvider(api string)
- func UsesMistralReasoningEffort(model Model) bool
- func ValidateOpenRouterImagesPayload(payload OpenRouterImagesPayload) error
- func ValidateThinkingLevelSupported(model Model, level string) error
- func ValidateToolArguments(tool Tool, toolCall ContentPart) (map[string]any, error)
- func ValidateToolCall(tools []Tool, toolCall ContentPart) (map[string]any, error)
- type APIProvider
- type APIProviderFuncs
- type APIProviderRegistration
- type AbortUsageExpectation
- type AnthropicCompat
- type AnthropicContentBlock
- type AnthropicImageSource
- type AnthropicMessage
- type AnthropicMessagesProvider
- type AnthropicPayload
- type AnthropicPayloadOptions
- type AnthropicRawUsage
- type AnthropicSSEEvent
- type AnthropicTool
- type AssistantImages
- func AbortedImages(model ImagesModel, err error) AssistantImages
- func ErrorImages(model ImagesModel, err error) AssistantImages
- func GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
- func ParseOpenRouterImagesResponse(model ImagesModel, response OpenRouterImagesResponse) AssistantImages
- type AssistantMessageDiagnostic
- type AssistantMessageEvent
- func ProcessBedrockConverseStreamEvents(model Model, output *Message, events []BedrockConverseStreamEvent) []AssistantMessageEvent
- func ProcessOpenAICodexStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent, ...) []AssistantMessageEvent
- func ProcessOpenAIResponsesStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent) []AssistantMessageEvent
- type AssistantMessageEventStream
- func CompletedAssistantStream(message Message) *AssistantMessageEventStream
- func ErrorAssistantStream(message Message) *AssistantMessageEventStream
- func NewAssistantMessageEventStream() *AssistantMessageEventStream
- func Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
- func StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
- type AzureOpenAIConfig
- type AzureOpenAIResponsesOptions
- type AzureOpenAIResponsesPayload
- type AzureOpenAIResponsesPayloadOptions
- type AzureOpenAIResponsesProvider
- type BedrockCachePoint
- type BedrockClientConfig
- type BedrockClientOptions
- type BedrockContentBlock
- type BedrockContentBlockDeltaEvent
- type BedrockContentBlockStartEvent
- type BedrockContentBlockStopEvent
- type BedrockConverseStreamEvent
- type BedrockConverseStreamProcessor
- type BedrockConverseStreamProvider
- type BedrockConverseStreamRequest
- type BedrockConverseStreamTransport
- type BedrockImageBlock
- type BedrockMessage
- type BedrockMessageStartEvent
- type BedrockMessageStopEvent
- type BedrockMetadataEvent
- type BedrockNamedToolChoice
- type BedrockPayload
- type BedrockPayloadOptions
- type BedrockReasoningContent
- type BedrockTool
- type BedrockToolConfig
- type BedrockToolInputSchema
- type BedrockToolResultBlock
- type BedrockToolSpec
- type BedrockToolUseBlock
- type BedrockUsage
- type ContentPart
- func FauxText(text string) ContentPart
- func FauxThinking(thinking string) ContentPart
- func FauxToolCall(name string, arguments map[string]any, id string) ContentPart
- func Image(data, mimeType string) ContentPart
- func Text(text string) ContentPart
- func Thinking(thinking string) ContentPart
- func ToolCall(id, name string, args map[string]any) ContentPart
- type Context
- type ConvertOpenAIResponsesOptions
- type DiagnosticErrorInfo
- type EventStream
- type FauxModelDefinition
- type FauxOption
- type FauxOptions
- type FauxProviderRegistration
- func (r *FauxProviderRegistration) AppendResponses(responses []FauxResponseStep)
- func (r *FauxProviderRegistration) GetModel(modelID ...string) (Model, bool)
- func (r *FauxProviderRegistration) MustModel(modelID ...string) Model
- func (r *FauxProviderRegistration) PendingResponseCount() int
- func (r *FauxProviderRegistration) SetResponses(responses []FauxResponseStep)
- func (r *FauxProviderRegistration) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
- func (r *FauxProviderRegistration) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
- func (r *FauxProviderRegistration) Unregister()
- type FauxResponseFactory
- type FauxResponseStep
- type FauxState
- type FauxTokenSize
- type GitHubCopilotDevicePollResponse
- type GoogleCandidate
- type GoogleContent
- type GoogleFunctionCall
- type GoogleFunctionDeclaration
- type GoogleFunctionResponse
- type GoogleGenerateConfig
- type GoogleInlineData
- type GooglePart
- type GooglePayload
- type GooglePayloadOptions
- type GoogleProvider
- type GoogleStreamChunk
- type GoogleSystemContent
- type GoogleThinkingConfig
- type GoogleThinkingOptions
- type GoogleToolGroup
- type GoogleUsageMetadata
- type GoogleVertexClientConfig
- type GoogleVertexHTTPOptions
- type GoogleVertexOptions
- type HTTPDoer
- type ImagesAPIProvider
- type ImagesAPIProviderFuncs
- type ImagesContent
- type ImagesContext
- type ImagesModel
- type ImagesOptions
- type Message
- func AssistantErrorMessage(message string, model Model, aborted bool) Message
- func AssistantMessage(content []ContentPart, stopReason string, model Model) Message
- func Complete(ctx context.Context, model Model, llmContext Context, options StreamOptions) (Message, error)
- func CompleteSimple(ctx context.Context, model Model, llmContext Context, ...) (Message, error)
- func FauxAssistantMessage(content []ContentPart, stopReason string) Message
- func FauxAssistantText(text string) Message
- func ProcessAnthropicSSEEvents(model Model, events []AnthropicSSEEvent) (Message, error)
- func ProcessOpenAICompletionsChunks(model Model, chunks []*OpenAIChatCompletionChunk) Message
- func TransformMessages(messages []Message, model Model, normalizeToolCallID NormalizeToolCallIDFunc) []Message
- func UserMessageText(text string) Message
- type MistralCompletionChoice
- type MistralCompletionChunk
- type MistralContentPart
- type MistralDelta
- type MistralMessage
- type MistralPayload
- type MistralPayloadOptions
- type MistralProvider
- type MistralStreamEvent
- type MistralStreamToolCall
- type MistralText
- type MistralTool
- type MistralToolCall
- type MistralToolCallFunction
- type MistralToolFunction
- type MistralUsage
- type Model
- type ModelCompat
- type ModelCost
- type NormalizeToolCallIDFunc
- type OAuthCredentials
- type OAuthPageOptions
- type OAuthTokenRequest
- type OpenAIChatCompletionChoice
- type OpenAIChatCompletionChunk
- type OpenAIChatCompletionTokenDetails
- type OpenAIChatContentPart
- type OpenAIChatDelta
- type OpenAIChatImageURL
- type OpenAIChatMessage
- type OpenAIChatPromptTokenDetails
- type OpenAIChatTool
- type OpenAIChatToolCall
- type OpenAIChatToolCallDelta
- type OpenAIChatToolCallFunction
- type OpenAIChatToolCallFunctionDelta
- type OpenAIChatToolFunction
- type OpenAIChatUsage
- type OpenAICodexProcessOptions
- type OpenAICodexResponsesPayload
- type OpenAICodexResponsesPayloadOptions
- type OpenAICodexResponsesProvider
- type OpenAICodexWebSocketDebugStats
- type OpenAICompatCacheControl
- type OpenAICompletionsCompat
- type OpenAICompletionsPayload
- type OpenAICompletionsPayloadOptions
- type OpenAICompletionsProvider
- type OpenAICompletionsStreamProcessor
- type OpenAIResponsesCompat
- type OpenAIResponsesContentPart
- type OpenAIResponsesIncompleteDetails
- type OpenAIResponsesInputItem
- type OpenAIResponsesInputTokenDetails
- type OpenAIResponsesOutputContentPart
- type OpenAIResponsesOutputItem
- type OpenAIResponsesPayload
- type OpenAIResponsesPayloadOptions
- type OpenAIResponsesProvider
- type OpenAIResponsesResponseEvent
- type OpenAIResponsesStreamEvent
- type OpenAIResponsesStreamProcessor
- type OpenAIResponsesTool
- type OpenAIResponsesUsage
- type OpenRouterGeneratedImage
- type OpenRouterImagesChoice
- type OpenRouterImagesChoiceMessage
- type OpenRouterImagesContentPart
- type OpenRouterImagesImageURL
- type OpenRouterImagesMessage
- type OpenRouterImagesPayload
- type OpenRouterImagesProvider
- type OpenRouterImagesResponse
- type OpenRouterImagesUsage
- type OpenRouterPromptTokensDetails
- type Schema
- func Boolean() Schema
- func Integer() Schema
- func Null() Schema
- func Number() Schema
- func Object(properties map[string]Schema, required ...string) Schema
- func String() Schema
- func StringEnum(values ...string) Schema
- func StringEnumWithOptions(values []string, options StringEnumOptions) Schema
- func TypeUnion(types ...string) Schema
- type SessionResourceCleanup
- type SessionResourceCleanupError
- type SimpleStreamOptions
- type StreamOptions
- type StringEnumOptions
- type Tool
- type Usage
- func EmptyUsage() Usage
- func ParseGoogleUsage(raw GoogleUsageMetadata, model Model) Usage
- func ParseMistralUsage(raw MistralUsage, model Model) Usage
- func ParseOpenAIChatUsage(raw OpenAIChatUsage, model Model) Usage
- func ParseOpenAIResponsesUsage(raw OpenAIResponsesUsage, model Model) Usage
- func ParseOpenRouterImagesUsage(raw OpenRouterImagesUsage, model ImagesModel) Usage
- type UsageCost
Constants ¶
View Source
const ( CloudflareWorkersAIBaseURL = "https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1" CloudflareAIGatewayCompatBaseURL = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat" CloudflareAIGatewayOpenAIBaseURL = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai" CloudflareAIGatewayAnthropicBaseURL = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic" )
View Source
const ( ImagesStopReasonStop = "stop" ImagesStopReasonError = "error" ImagesStopReasonAborted = "aborted" )
View Source
const ( NonVisionUserImagePlaceholder = "(image omitted: model does not support images)" NonVisionToolImagePlaceholder = "(tool image omitted: model does not support images)" )
View Source
const ( AnthropicOAuthTokenURL = "https://platform.claude.com/v1/oauth/token" AnthropicOAuthClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e" )
View Source
const ( RoleUser = "user" RoleAssistant = "assistant" RoleToolResult = "toolResult" ContentText = "text" ContentThinking = "thinking" ContentImage = "image" ContentToolCall = "toolCall" StopReasonStop = "stop" StopReasonLength = "length" StopReasonError = "error" StopReasonAborted = "aborted" )
View Source
const BuiltInAPIProviderSourceID = "builtin"
View Source
const DefaultAzureOpenAIAPIVersion = "v1"
View Source
const GCPVertexCredentialsMarker = "gcp-vertex-credentials"
View Source
const StopReasonToolUse = "toolUse"
View Source
const UnsupportedProxyProtocolMessage = httpproxy.UnsupportedProxyProtocolMessage
Variables ¶
This section is empty.
Functions ¶
func AppendAssistantMessageDiagnostic ¶
func AppendAssistantMessageDiagnostic(message *Message, diagnostic AssistantMessageDiagnostic)
func ApplyOpenAIAnthropicCacheControl ¶
func ApplyOpenAIAnthropicCacheControl(messages []OpenAIChatMessage, tools []OpenAIChatTool, cacheControl *OpenAICompatCacheControl)
func BuildAnthropicHeaders ¶
func BuildAnthropicHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string
func BuildAnthropicRequestHeaders ¶
func BuildAnthropicRequestHeaders(model Model, context Context, options AnthropicPayloadOptions) map[string]string
func BuildBedrockAdditionalModelRequestFields ¶
func BuildBedrockAdditionalModelRequestFields(model Model, options BedrockPayloadOptions) map[string]any
func BuildOpenAICompletionsHeaders ¶
func BuildOpenAICompletionsHeaders(model Model, options OpenAICompletionsPayloadOptions) map[string]string
func BuildOpenAIResponsesHeaders ¶
func BuildOpenAIResponsesHeaders(model Model, options OpenAIResponsesPayloadOptions) map[string]string
func ClampThinkingLevel ¶
func CleanupSessionResources ¶
func ClearAPIProviders ¶
func ClearAPIProviders()
func CloseOpenAICodexWebSocketSessions ¶
func CloseOpenAICodexWebSocketSessions(sessionIDs ...string)
func FindEnvKeys ¶
func FormatThrownValue ¶
func FromClaudeCodeToolName ¶
func GetConfiguredBedrockRegion ¶
func GetConfiguredBedrockRegion(options BedrockClientOptions) string
func GetEnvAPIKey ¶
func GetImageProviders ¶
func GetImageProviders() []string
func GetOverflowPatterns ¶
func GetProviders ¶
func GetProviders() []string
func GitHubCopilotBaseURL ¶
func GitHubCopilotPollSchedule ¶
func GitHubCopilotPollSchedule(startMillis int64, intervalSeconds, expiresSeconds int, responses []GitHubCopilotDevicePollResponse) ([]int64, error)
func GoogleThinkingBudget ¶
func GoogleThinkingLevel ¶
func HasConfiguredBedrockProfile ¶
func HasConfiguredBedrockProfile(options BedrockClientOptions) bool
func HasCopilotVisionInput ¶
func InferCopilotInitiator ¶
func IsCloudflareProvider ¶
func IsContextOverflow ¶
func IsGoogleThinkingPart ¶
func IsGoogleThinkingPart(part GooglePart) bool
func IsGovCloudBedrockTarget ¶
func IsGovCloudBedrockTarget(model Model, options BedrockPayloadOptions) bool
func IsMalformedJSONError ¶
func IsOpenAICodexRetryable ¶
func IsPlaceholderAPIKey ¶
func MapGoogleFinishReason ¶
func ModelsAreEqual ¶
func OAuthErrorHTML ¶
func OAuthPageHTML ¶
func OAuthPageHTML(options OAuthPageOptions) string
func OAuthSuccessHTML ¶
func OpenAICodexRefreshError ¶
func OpenAICodexRetryDelay ¶
func RegisterAPIProvider ¶
func RegisterAPIProvider(api string, provider APIProvider)
func RegisterAPIProviderWithSource ¶
func RegisterAPIProviderWithSource(api string, provider APIProvider, sourceID string)
func RegisterBuiltInAPIProvider ¶
func RegisterBuiltInAPIProvider(api string, provider APIProvider)
func RegisterBuiltInAPIProviders ¶
func RegisterBuiltInAPIProviders()
func RegisterImageModel ¶
func RegisterImageModel(model ImagesModel)
func RegisterImagesAPIProvider ¶
func RegisterImagesAPIProvider(api string, provider ImagesAPIProvider)
func RegisterModel ¶
func RegisterModel(model Model)
func RegisterSessionResourceCleanup ¶
func RegisterSessionResourceCleanup(cleanup SessionResourceCleanup) func()
func RepairJSON ¶
func ResetAPIProviders ¶
func ResetAPIProviders()
func ResetOpenAICodexWebSocketDebugStats ¶
func ResetOpenAICodexWebSocketDebugStats(sessionIDs ...string)
func ResolveGoogleVertexAPIKey ¶
func ResolveGoogleVertexAPIKey(options GoogleVertexOptions) string
func ResolveOpenAICodexURL ¶
func SanitizeSurrogates ¶
func SchemaToMap ¶
func ToClaudeCodeToolName ¶
func UUIDLikeID ¶
func UUIDLikeID() string
func UnmarshalJSONWithRepair ¶
func UnregisterAPIProvider ¶
func UnregisterAPIProvider(api string)
func UnregisterAPIProviders ¶
func UnregisterAPIProviders(sourceID string)
func UnregisterImagesAPIProvider ¶
func UnregisterImagesAPIProvider(api string)
func ValidateOpenRouterImagesPayload ¶
func ValidateOpenRouterImagesPayload(payload OpenRouterImagesPayload) error
func ValidateToolArguments ¶
func ValidateToolArguments(tool Tool, toolCall ContentPart) (map[string]any, error)
func ValidateToolCall ¶
func ValidateToolCall(tools []Tool, toolCall ContentPart) (map[string]any, error)
Types ¶
type APIProvider ¶
type APIProvider interface {
Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
}
func GetAPIProvider ¶
func GetAPIProvider(api string) APIProvider
type APIProviderFuncs ¶
type APIProviderFuncs struct {
StreamFunc func(Model, Context, StreamOptions) (*AssistantMessageEventStream, error)
StreamSimpleFunc func(Model, Context, SimpleStreamOptions) (*AssistantMessageEventStream, error)
}
func (APIProviderFuncs) Stream ¶
func (p APIProviderFuncs) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (APIProviderFuncs) StreamSimple ¶
func (p APIProviderFuncs) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type APIProviderRegistration ¶
type APIProviderRegistration struct {
API string
Provider APIProvider
SourceID string
}
func GetAPIProviders ¶
func GetAPIProviders() []APIProviderRegistration
type AbortUsageExpectation ¶
type AbortUsageExpectation string
const ( AbortUsageFinalOnly AbortUsageExpectation = "final-only" AbortUsageInputOnly AbortUsageExpectation = "input-only" AbortUsageIncremental AbortUsageExpectation = "incremental" )
func ExpectedAbortUsage ¶
func ExpectedAbortUsage(model Model) AbortUsageExpectation
type AnthropicCompat ¶
type AnthropicCompat struct {
SupportsEagerToolInputStreaming bool
SupportsCacheControlOnTools bool
SupportsLongCacheRetention bool
SendSessionAffinityHeaders bool
}
func ResolveAnthropicCompat ¶
func ResolveAnthropicCompat(model Model) AnthropicCompat
type AnthropicContentBlock ¶
type AnthropicContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Source *AnthropicImageSource `json:"source,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input map[string]any `json:"input,omitempty"`
ToolUseID string `json:"tool_use_id,omitempty"`
Content any `json:"content,omitempty"`
IsError bool `json:"is_error,omitempty"`
Thinking string `json:"thinking,omitempty"`
Signature string `json:"signature,omitempty"`
Data string `json:"data,omitempty"`
CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}
type AnthropicImageSource ¶
type AnthropicMessage ¶
func ConvertAnthropicMessages ¶
func ConvertAnthropicMessages(model Model, context Context, isOAuthToken bool, cacheControl *OpenAICompatCacheControl) []AnthropicMessage
type AnthropicMessagesProvider ¶
type AnthropicMessagesProvider struct {
Client HTTPDoer
}
func NewAnthropicMessagesProvider ¶
func NewAnthropicMessagesProvider(client HTTPDoer) AnthropicMessagesProvider
func (AnthropicMessagesProvider) Stream ¶
func (p AnthropicMessagesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (AnthropicMessagesProvider) StreamSimple ¶
func (p AnthropicMessagesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type AnthropicPayload ¶
type AnthropicPayload struct {
Model string `json:"model"`
Messages []AnthropicMessage `json:"messages"`
System []AnthropicContentBlock `json:"system,omitempty"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
Temperature *float64 `json:"temperature,omitempty"`
Tools []AnthropicTool `json:"tools,omitempty"`
Thinking map[string]any `json:"thinking,omitempty"`
OutputConfig map[string]any `json:"output_config,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
func BuildAnthropicPayload ¶
func BuildAnthropicPayload(model Model, context Context, options AnthropicPayloadOptions) AnthropicPayload
type AnthropicPayloadOptions ¶
type AnthropicRawUsage ¶
type AnthropicSSEEvent ¶
type AnthropicTool ¶
type AnthropicTool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
EagerInputStreaming *bool `json:"eager_input_streaming,omitempty"`
InputSchema map[string]any `json:"input_schema"`
CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}
func ConvertAnthropicTools ¶
func ConvertAnthropicTools(tools []Tool, isOAuthToken bool, supportsEagerToolInputStreaming bool, cacheControl *OpenAICompatCacheControl) []AnthropicTool
type AssistantImages ¶
type AssistantImages struct {
API string
Provider string
Model string
Output []ImagesContent
ResponseID string
Usage Usage
StopReason string
ErrorMessage string
Timestamp int64
}
func AbortedImages ¶
func AbortedImages(model ImagesModel, err error) AssistantImages
func ErrorImages ¶
func ErrorImages(model ImagesModel, err error) AssistantImages
func GenerateImages ¶
func GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
func ParseOpenRouterImagesResponse ¶
func ParseOpenRouterImagesResponse(model ImagesModel, response OpenRouterImagesResponse) AssistantImages
type AssistantMessageDiagnostic ¶
type AssistantMessageDiagnostic struct {
Type string `json:"type"`
Timestamp int64 `json:"timestamp"`
Error *DiagnosticErrorInfo `json:"error,omitempty"`
Details map[string]any `json:"details,omitempty"`
}
func NewAssistantMessageDiagnostic ¶
func NewAssistantMessageDiagnostic(diagnosticType string, err error, details map[string]any) AssistantMessageDiagnostic
type AssistantMessageEvent ¶
type AssistantMessageEvent struct {
Type string `json:"type"`
Partial Message `json:"partial,omitempty"`
Message Message `json:"message,omitempty"`
Error Message `json:"error,omitempty"`
Reason string `json:"reason,omitempty"`
ContentIndex int `json:"contentIndex,omitempty"`
Delta string `json:"delta,omitempty"`
Content string `json:"content,omitempty"`
ToolCall ContentPart `json:"toolCall,omitempty"`
}
func ProcessBedrockConverseStreamEvents ¶
func ProcessBedrockConverseStreamEvents(model Model, output *Message, events []BedrockConverseStreamEvent) []AssistantMessageEvent
func ProcessOpenAICodexStreamEvents ¶
func ProcessOpenAICodexStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent, options OpenAICodexProcessOptions) []AssistantMessageEvent
func ProcessOpenAIResponsesStreamEvents ¶
func ProcessOpenAIResponsesStreamEvents(model Model, output *Message, events []OpenAIResponsesStreamEvent) []AssistantMessageEvent
type AssistantMessageEventStream ¶
type AssistantMessageEventStream = EventStream[AssistantMessageEvent, Message]
func CompletedAssistantStream ¶
func CompletedAssistantStream(message Message) *AssistantMessageEventStream
func ErrorAssistantStream ¶
func ErrorAssistantStream(message Message) *AssistantMessageEventStream
func NewAssistantMessageEventStream ¶
func NewAssistantMessageEventStream() *AssistantMessageEventStream
func Stream ¶
func Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func StreamSimple ¶
func StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type AzureOpenAIConfig ¶
func ResolveAzureOpenAIConfig ¶
func ResolveAzureOpenAIConfig(model Model, options AzureOpenAIResponsesOptions) (AzureOpenAIConfig, error)
type AzureOpenAIResponsesPayload ¶
type AzureOpenAIResponsesPayload struct {
Model string `json:"model"`
Input []OpenAIResponsesInputItem `json:"input"`
Stream bool `json:"stream"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Tools []OpenAIResponsesTool `json:"tools,omitempty"`
Reasoning map[string]string `json:"reasoning,omitempty"`
Include []string `json:"include,omitempty"`
}
func BuildAzureOpenAIResponsesPayload ¶
func BuildAzureOpenAIResponsesPayload(model Model, context Context, options AzureOpenAIResponsesPayloadOptions) AzureOpenAIResponsesPayload
type AzureOpenAIResponsesProvider ¶
type AzureOpenAIResponsesProvider struct {
Client HTTPDoer
}
func NewAzureOpenAIResponsesProvider ¶
func NewAzureOpenAIResponsesProvider(client HTTPDoer) AzureOpenAIResponsesProvider
func (AzureOpenAIResponsesProvider) Stream ¶
func (p AzureOpenAIResponsesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (AzureOpenAIResponsesProvider) StreamSimple ¶
func (p AzureOpenAIResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type BedrockCachePoint ¶
type BedrockClientConfig ¶
func ResolveBedrockClientConfig ¶
func ResolveBedrockClientConfig(model Model, options BedrockClientOptions) BedrockClientConfig
type BedrockClientOptions ¶
type BedrockContentBlock ¶
type BedrockContentBlock struct {
Text string
Image *BedrockImageBlock
ToolUse *BedrockToolUseBlock
ToolResult *BedrockToolResultBlock
ReasoningContent *BedrockReasoningContent
CachePoint *BedrockCachePoint
}
type BedrockContentBlockDeltaEvent ¶
type BedrockContentBlockDeltaEvent struct {
ContentBlockIndex int
Text string
ToolUseInput string
ReasoningContent *BedrockReasoningContent
}
type BedrockContentBlockStartEvent ¶
type BedrockContentBlockStartEvent struct {
ContentBlockIndex int
ToolUse *BedrockToolUseBlock
}
type BedrockContentBlockStopEvent ¶
type BedrockContentBlockStopEvent struct {
ContentBlockIndex int
}
type BedrockConverseStreamEvent ¶
type BedrockConverseStreamEvent struct {
MessageStart *BedrockMessageStartEvent
ContentBlockStart *BedrockContentBlockStartEvent
ContentBlockDelta *BedrockContentBlockDeltaEvent
ContentBlockStop *BedrockContentBlockStopEvent
MessageStop *BedrockMessageStopEvent
Metadata *BedrockMetadataEvent
Error error
}
type BedrockConverseStreamProcessor ¶
type BedrockConverseStreamProcessor struct {
// contains filtered or unexported fields
}
func NewBedrockConverseStreamProcessor ¶
func NewBedrockConverseStreamProcessor(model Model, output *Message) *BedrockConverseStreamProcessor
func (*BedrockConverseStreamProcessor) Process ¶
func (p *BedrockConverseStreamProcessor) Process(event BedrockConverseStreamEvent) []AssistantMessageEvent
type BedrockConverseStreamProvider ¶
type BedrockConverseStreamProvider struct {
Transport BedrockConverseStreamTransport
}
func NewBedrockConverseStreamProvider ¶
func NewBedrockConverseStreamProvider(transport BedrockConverseStreamTransport) BedrockConverseStreamProvider
func (BedrockConverseStreamProvider) Stream ¶
func (p BedrockConverseStreamProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (BedrockConverseStreamProvider) StreamSimple ¶
func (p BedrockConverseStreamProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type BedrockConverseStreamRequest ¶
type BedrockConverseStreamRequest struct {
Model Model
Payload BedrockPayload
ClientConfig BedrockClientConfig
MaxTokens int
Temperature *float64
CacheRetention string
RequestMetadata map[string]string
}
type BedrockConverseStreamTransport ¶
type BedrockConverseStreamTransport func(context.Context, BedrockConverseStreamRequest) (<-chan BedrockConverseStreamEvent, error)
type BedrockImageBlock ¶
type BedrockMessage ¶
type BedrockMessage struct {
Role string
Content []BedrockContentBlock
}
func ConvertBedrockMessages ¶
func ConvertBedrockMessages(model Model, context Context, cacheRetention string, forcePromptCache bool) []BedrockMessage
type BedrockMessageStartEvent ¶
type BedrockMessageStartEvent struct {
Role string
}
type BedrockMessageStopEvent ¶
type BedrockMessageStopEvent struct {
StopReason string
}
type BedrockMetadataEvent ¶
type BedrockMetadataEvent struct {
Usage BedrockUsage
}
type BedrockNamedToolChoice ¶
type BedrockPayload ¶
type BedrockPayload struct {
System []BedrockContentBlock
Messages []BedrockMessage
ToolConfig *BedrockToolConfig
AdditionalModelRequestFields map[string]any
}
func BuildBedrockPayload ¶
func BuildBedrockPayload(model Model, context Context, options BedrockPayloadOptions) BedrockPayload
type BedrockPayloadOptions ¶
type BedrockReasoningContent ¶
type BedrockTool ¶
type BedrockTool struct {
ToolSpec BedrockToolSpec
}
type BedrockToolConfig ¶
type BedrockToolConfig struct {
Tools []BedrockTool
ToolChoice any
}
func ConvertBedrockToolConfig ¶
func ConvertBedrockToolConfig(tools []Tool, toolChoice any) *BedrockToolConfig
type BedrockToolInputSchema ¶
type BedrockToolResultBlock ¶
type BedrockToolResultBlock struct {
ToolUseID string
Content []BedrockContentBlock
Status string
}
type BedrockToolSpec ¶
type BedrockToolSpec struct {
Name string
Description string
InputSchema BedrockToolInputSchema
}
type BedrockToolUseBlock ¶
type BedrockUsage ¶
type ContentPart ¶
type ContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
TextSignature string `json:"textSignature,omitempty"`
Thinking string `json:"thinking,omitempty"`
ThinkingSignature string `json:"thinkingSignature,omitempty"`
Redacted bool `json:"redacted,omitempty"`
Data string `json:"data,omitempty"`
MIMEType string `json:"mimeType,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Arguments map[string]any `json:"arguments,omitempty"`
ThoughtSignature string `json:"thoughtSignature,omitempty"`
}
func FauxText ¶
func FauxText(text string) ContentPart
func FauxThinking ¶
func FauxThinking(thinking string) ContentPart
func FauxToolCall ¶
func FauxToolCall(name string, arguments map[string]any, id string) ContentPart
func Image ¶
func Image(data, mimeType string) ContentPart
func Text ¶
func Text(text string) ContentPart
func Thinking ¶
func Thinking(thinking string) ContentPart
type DiagnosticErrorInfo ¶
type DiagnosticErrorInfo struct {
Name string `json:"name,omitempty"`
Message string `json:"message"`
Stack string `json:"stack,omitempty"`
Code any `json:"code,omitempty"`
}
func ExtractDiagnosticError ¶
func ExtractDiagnosticError(value any) DiagnosticErrorInfo
type EventStream ¶
type EventStream[T any, R any] struct { *eventstream.EventStream[T, R] }
func NewEventStream ¶
func NewEventStream[T any, R any](isComplete func(T) bool, extract func(T) R) *EventStream[T, R]
type FauxModelDefinition ¶
type FauxOption ¶
type FauxOption func(*FauxOptions)
func WithFauxAPI ¶
func WithFauxAPI(api string) FauxOption
func WithFauxModels ¶
func WithFauxModels(models ...FauxModelDefinition) FauxOption
func WithFauxProvider ¶
func WithFauxProvider(provider string) FauxOption
func WithFauxTokenSize ¶
func WithFauxTokenSize(min, max int) FauxOption
func WithFauxTokensPerSecond ¶
func WithFauxTokensPerSecond(tokensPerSecond float64) FauxOption
type FauxOptions ¶
type FauxOptions struct {
API string
Provider string
Models []FauxModelDefinition
TokensPerSecond float64
TokenSize FauxTokenSize
}
type FauxProviderRegistration ¶
type FauxProviderRegistration struct {
API string
Provider string
Models []Model
State FauxState
// contains filtered or unexported fields
}
func RegisterFauxProvider ¶
func RegisterFauxProvider(options ...FauxOption) *FauxProviderRegistration
func (*FauxProviderRegistration) AppendResponses ¶
func (r *FauxProviderRegistration) AppendResponses(responses []FauxResponseStep)
func (*FauxProviderRegistration) GetModel ¶
func (r *FauxProviderRegistration) GetModel(modelID ...string) (Model, bool)
func (*FauxProviderRegistration) MustModel ¶
func (r *FauxProviderRegistration) MustModel(modelID ...string) Model
func (*FauxProviderRegistration) PendingResponseCount ¶
func (r *FauxProviderRegistration) PendingResponseCount() int
func (*FauxProviderRegistration) SetResponses ¶
func (r *FauxProviderRegistration) SetResponses(responses []FauxResponseStep)
func (*FauxProviderRegistration) Stream ¶
func (r *FauxProviderRegistration) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (*FauxProviderRegistration) StreamSimple ¶
func (r *FauxProviderRegistration) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
func (*FauxProviderRegistration) Unregister ¶
func (r *FauxProviderRegistration) Unregister()
type FauxResponseFactory ¶
type FauxResponseStep ¶
type FauxResponseStep struct {
Message Message
Factory FauxResponseFactory
}
type FauxTokenSize ¶
type GoogleCandidate ¶
type GoogleCandidate struct {
Content GoogleContent `json:"content"`
FinishReason string `json:"finishReason"`
}
type GoogleContent ¶
type GoogleContent struct {
Role string `json:"role"`
Parts []GooglePart `json:"parts"`
}
func ConvertGoogleMessages ¶
func ConvertGoogleMessages(model Model, context Context) []GoogleContent
type GoogleFunctionCall ¶
type GoogleFunctionResponse ¶
type GoogleFunctionResponse struct {
Name string `json:"name"`
Response map[string]any `json:"response"`
Parts []GooglePart `json:"parts,omitempty"`
ID string `json:"id,omitempty"`
}
type GoogleGenerateConfig ¶
type GoogleGenerateConfig struct {
Temperature *float64 `json:"temperature,omitempty"`
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
SystemInstruction *GoogleSystemContent `json:"systemInstruction,omitempty"`
ThinkingConfig *GoogleThinkingConfig `json:"thinkingConfig,omitempty"`
}
type GoogleInlineData ¶
type GooglePart ¶
type GooglePart struct {
Text string `json:"text,omitempty"`
Thought bool `json:"thought,omitempty"`
ThoughtSignature string `json:"thoughtSignature,omitempty"`
InlineData *GoogleInlineData `json:"inlineData,omitempty"`
FunctionCall *GoogleFunctionCall `json:"functionCall,omitempty"`
FunctionResponse *GoogleFunctionResponse `json:"functionResponse,omitempty"`
}
type GooglePayload ¶
type GooglePayload struct {
Model string `json:"-"`
Contents []GoogleContent `json:"contents"`
Tools []GoogleToolGroup `json:"tools,omitempty"`
Config GoogleGenerateConfig `json:"generationConfig,omitempty"`
}
func BuildGooglePayload ¶
func BuildGooglePayload(model Model, llmContext Context, options GooglePayloadOptions) GooglePayload
type GooglePayloadOptions ¶
type GoogleProvider ¶
type GoogleProvider struct {
Client HTTPDoer
}
func NewGoogleProvider ¶
func NewGoogleProvider(client HTTPDoer) GoogleProvider
func (GoogleProvider) Stream ¶
func (p GoogleProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (GoogleProvider) StreamSimple ¶
func (p GoogleProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type GoogleStreamChunk ¶
type GoogleStreamChunk struct {
ResponseID string `json:"responseId"`
Candidates []GoogleCandidate `json:"candidates"`
UsageMetadata *GoogleUsageMetadata `json:"usageMetadata,omitempty"`
}
func DecodeGoogleStreamChunk ¶
func DecodeGoogleStreamChunk(data []byte) (GoogleStreamChunk, error)
type GoogleSystemContent ¶
type GoogleSystemContent struct {
Parts []GooglePart `json:"parts"`
}
type GoogleThinkingConfig ¶
type GoogleThinkingConfig struct {
IncludeThoughts *bool `json:"includeThoughts,omitempty"`
ThinkingLevel string `json:"thinkingLevel,omitempty"`
ThinkingBudget *int `json:"thinkingBudget,omitempty"`
}
func BuildGoogleThinkingConfig ¶
func BuildGoogleThinkingConfig(model Model, options GoogleThinkingOptions) *GoogleThinkingConfig
func DisabledGoogleThinkingConfig ¶
func DisabledGoogleThinkingConfig(model Model) *GoogleThinkingConfig
type GoogleThinkingOptions ¶
type GoogleToolGroup ¶
type GoogleToolGroup struct {
FunctionDeclarations []GoogleFunctionDeclaration `json:"functionDeclarations"`
}
func ConvertGoogleTools ¶
func ConvertGoogleTools(tools []Tool, useParameters bool) []GoogleToolGroup
type GoogleUsageMetadata ¶
type GoogleVertexClientConfig ¶
type GoogleVertexClientConfig struct {
VertexAI bool
APIKey string
Project string
Location string
APIVersion string
HTTPOptions *GoogleVertexHTTPOptions
}
func ResolveGoogleVertexClientConfig ¶
func ResolveGoogleVertexClientConfig(model Model, options GoogleVertexOptions) GoogleVertexClientConfig
type GoogleVertexHTTPOptions ¶
type GoogleVertexOptions ¶
type ImagesAPIProvider ¶
type ImagesAPIProvider interface {
GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
}
func GetImagesAPIProvider ¶
func GetImagesAPIProvider(api string) ImagesAPIProvider
type ImagesAPIProviderFuncs ¶
type ImagesAPIProviderFuncs struct {
GenerateImagesFunc func(ImagesModel, ImagesContext, ImagesOptions) (AssistantImages, error)
}
func (ImagesAPIProviderFuncs) GenerateImages ¶
func (p ImagesAPIProviderFuncs) GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
type ImagesContent ¶
func ImageData ¶
func ImageData(data, mimeType string) ImagesContent
func ImageText ¶
func ImageText(text string) ImagesContent
type ImagesContext ¶
type ImagesContext struct {
Input []ImagesContent
}
type ImagesModel ¶
type ImagesModel struct {
ID string
Name string
API string
Provider string
BaseURL string
Input []string
Output []string
Cost ModelCost
Headers map[string]string
}
func GetImageModel ¶
func GetImageModel(provider, id string) (ImagesModel, bool)
func GetImageModels ¶
func GetImageModels(provider string) []ImagesModel
func MustGetImageModel ¶
func MustGetImageModel(provider, id string) ImagesModel
type ImagesOptions ¶
type Message ¶
type Message struct {
Role string `json:"role"`
Content []ContentPart `json:"content,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
API string `json:"api,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Diagnostics []AssistantMessageDiagnostic `json:"diagnostics,omitempty"`
Usage Usage `json:"usage,omitempty"`
StopReason string `json:"stopReason,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
ResponseID string `json:"responseId,omitempty"`
ToolCallID string `json:"toolCallID,omitempty"`
ToolName string `json:"toolName,omitempty"`
CustomType string `json:"customType,omitempty"`
Display *bool `json:"display,omitempty"`
Details any `json:"details,omitempty"`
IsError bool `json:"isError,omitempty"`
}
func AssistantErrorMessage ¶
func AssistantMessage ¶
func AssistantMessage(content []ContentPart, stopReason string, model Model) Message
func CompleteSimple ¶
func FauxAssistantMessage ¶
func FauxAssistantMessage(content []ContentPart, stopReason string) Message
func FauxAssistantText ¶
func ProcessAnthropicSSEEvents ¶
func ProcessAnthropicSSEEvents(model Model, events []AnthropicSSEEvent) (Message, error)
func ProcessOpenAICompletionsChunks ¶
func ProcessOpenAICompletionsChunks(model Model, chunks []*OpenAIChatCompletionChunk) Message
func TransformMessages ¶
func TransformMessages(messages []Message, model Model, normalizeToolCallID NormalizeToolCallIDFunc) []Message
func UserMessageText ¶
type MistralCompletionChoice ¶
type MistralCompletionChoice struct {
Delta MistralDelta `json:"delta"`
FinishReason string `json:"finish_reason"`
}
type MistralCompletionChunk ¶
type MistralCompletionChunk struct {
ID string `json:"id"`
Choices []MistralCompletionChoice `json:"choices"`
Usage *MistralUsage `json:"usage,omitempty"`
}
func DecodeMistralCompletionChunk ¶
func DecodeMistralCompletionChunk(data []byte) (MistralCompletionChunk, error)
type MistralContentPart ¶
type MistralContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL string `json:"image_url,omitempty"`
Thinking []MistralText `json:"thinking,omitempty"`
}
type MistralDelta ¶
type MistralDelta struct {
Content json.RawMessage `json:"content,omitempty"`
ToolCalls []MistralStreamToolCall `json:"tool_calls,omitempty"`
}
type MistralMessage ¶
type MistralMessage struct {
Role string `json:"role"`
Content any `json:"content,omitempty"`
ToolCalls []MistralToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"`
}
func ConvertMistralMessages ¶
func ConvertMistralMessages(model Model, context Context) []MistralMessage
type MistralPayload ¶
type MistralPayload struct {
Model string `json:"model"`
Messages []MistralMessage `json:"messages"`
Tools []MistralTool `json:"tools,omitempty"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
PromptMode string `json:"prompt_mode,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
}
func BuildMistralPayload ¶
func BuildMistralPayload(model Model, context Context, options MistralPayloadOptions) MistralPayload
type MistralPayloadOptions ¶
type MistralProvider ¶
type MistralProvider struct {
Client HTTPDoer
}
func NewMistralProvider ¶
func NewMistralProvider(client HTTPDoer) MistralProvider
func (MistralProvider) Stream ¶
func (p MistralProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (MistralProvider) StreamSimple ¶
func (p MistralProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type MistralStreamEvent ¶
type MistralStreamEvent struct {
Data MistralCompletionChunk `json:"data"`
}
type MistralStreamToolCall ¶
type MistralStreamToolCall struct {
Index *int `json:"index,omitempty"`
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Function MistralToolCallFunction `json:"function"`
}
type MistralText ¶
type MistralTool ¶
type MistralTool struct {
Type string `json:"type"`
Function MistralToolFunction `json:"function"`
}
func ConvertMistralTools ¶
func ConvertMistralTools(tools []Tool) []MistralTool
type MistralToolCall ¶
type MistralToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function MistralToolCallFunction `json:"function"`
}
type MistralToolCallFunction ¶
type MistralToolFunction ¶
type MistralUsage ¶
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
API string `json:"api"`
Provider string `json:"provider"`
BaseURL string `json:"baseUrl,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Compat ModelCompat `json:"compat,omitempty"`
Reasoning bool `json:"reasoning"`
Input []string `json:"input,omitempty"`
Cost ModelCost `json:"cost"`
ContextWindow int `json:"contextWindow"`
MaxTokens int `json:"maxTokens"`
ThinkingLevelMap map[string]*string `json:"thinkingLevelMap,omitempty"`
}
func MustGetModel ¶
type ModelCompat ¶
type ModelCompat struct {
SupportsStore *bool `json:"supportsStore,omitempty"`
SupportsDeveloperRole *bool `json:"supportsDeveloperRole,omitempty"`
SupportsReasoningEffort *bool `json:"supportsReasoningEffort,omitempty"`
SupportsUsageInStreaming *bool `json:"supportsUsageInStreaming,omitempty"`
SupportsStrictMode *bool `json:"supportsStrictMode,omitempty"`
SupportsLongCacheRetention *bool `json:"supportsLongCacheRetention,omitempty"`
SupportsEagerToolInputStreaming *bool `json:"supportsEagerToolInputStreaming,omitempty"`
SupportsCacheControlOnTools *bool `json:"supportsCacheControlOnTools,omitempty"`
ForceAdaptiveThinking *bool `json:"forceAdaptiveThinking,omitempty"`
SendSessionAffinityHeaders *bool `json:"sendSessionAffinityHeaders,omitempty"`
SendSessionIDHeader *bool `json:"sendSessionIdHeader,omitempty"`
RequiresToolResultName *bool `json:"requiresToolResultName,omitempty"`
RequiresAssistantAfterToolResult *bool `json:"requiresAssistantAfterToolResult,omitempty"`
RequiresThinkingAsText *bool `json:"requiresThinkingAsText,omitempty"`
RequiresReasoningContentOnAssistantTurns *bool `json:"requiresReasoningContentOnAssistantTurns,omitempty"`
RequiresReasoningContentOnAssistantEvents *bool `json:"requiresReasoningContentOnAssistantEvents,omitempty"`
ZAIToolStream *bool `json:"zaiToolStream,omitempty"`
OpenRouterRouting map[string]any `json:"openRouterRouting,omitempty"`
VercelGatewayRouting map[string]any `json:"vercelGatewayRouting,omitempty"`
MaxTokensField string `json:"maxTokensField,omitempty"`
ThinkingFormat string `json:"thinkingFormat,omitempty"`
CacheControlFormat string `json:"cacheControlFormat,omitempty"`
}
type NormalizeToolCallIDFunc ¶
type OAuthCredentials ¶
type OAuthPageOptions ¶
type OAuthPageOptions = oauthpage.OAuthPageOptions
type OAuthTokenRequest ¶
func BuildAnthropicAuthorizationCodeTokenRequest ¶
func BuildAnthropicAuthorizationCodeTokenRequest(code, redirectURI string) OAuthTokenRequest
func BuildAnthropicRefreshTokenRequest ¶
func BuildAnthropicRefreshTokenRequest(refreshToken string) OAuthTokenRequest
type OpenAIChatCompletionChoice ¶
type OpenAIChatCompletionChoice struct {
Delta OpenAIChatDelta `json:"delta"`
FinishReason *string `json:"finish_reason"`
Usage *OpenAIChatUsage `json:"usage,omitempty"`
}
type OpenAIChatCompletionChunk ¶
type OpenAIChatCompletionChunk struct {
ID string `json:"id"`
Choices []OpenAIChatCompletionChoice `json:"choices"`
Usage *OpenAIChatUsage `json:"usage,omitempty"`
}
func DecodeOpenAIChatCompletionChunk ¶
func DecodeOpenAIChatCompletionChunk(data []byte) (OpenAIChatCompletionChunk, error)
type OpenAIChatCompletionTokenDetails ¶
type OpenAIChatCompletionTokenDetails struct {
ReasoningTokens int `json:"reasoning_tokens"`
}
type OpenAIChatContentPart ¶
type OpenAIChatContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *OpenAIChatImageURL `json:"image_url,omitempty"`
CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}
type OpenAIChatDelta ¶
type OpenAIChatDelta struct {
Content string `json:"content,omitempty"`
ReasoningContent string `json:"reasoning_content,omitempty"`
Reasoning string `json:"reasoning,omitempty"`
ReasoningText string `json:"reasoning_text,omitempty"`
ToolCalls []OpenAIChatToolCallDelta `json:"tool_calls,omitempty"`
}
type OpenAIChatImageURL ¶
type OpenAIChatImageURL struct {
URL string `json:"url"`
}
type OpenAIChatMessage ¶
type OpenAIChatMessage struct {
Role string `json:"role"`
Content any `json:"content,omitempty"`
ToolCalls []OpenAIChatToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"`
ReasoningContent string `json:"reasoning_content,omitempty"`
Reasoning string `json:"reasoning,omitempty"`
ReasoningText string `json:"reasoning_text,omitempty"`
ReasoningDetails []map[string]any `json:"reasoning_details,omitempty"`
Extra map[string]any `json:"-"`
// contains filtered or unexported fields
}
func ConvertOpenAICompletionsMessages ¶
func ConvertOpenAICompletionsMessages(model Model, context Context, compat OpenAICompletionsCompat) []OpenAIChatMessage
func (OpenAIChatMessage) MarshalJSON ¶
func (m OpenAIChatMessage) MarshalJSON() ([]byte, error)
type OpenAIChatTool ¶
type OpenAIChatTool struct {
Type string `json:"type"`
Function OpenAIChatToolFunction `json:"function"`
CacheControl *OpenAICompatCacheControl `json:"cache_control,omitempty"`
}
func ConvertOpenAICompletionsTools ¶
func ConvertOpenAICompletionsTools(tools []Tool, compat OpenAICompletionsCompat) []OpenAIChatTool
type OpenAIChatToolCall ¶
type OpenAIChatToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function OpenAIChatToolCallFunction `json:"function"`
}
type OpenAIChatToolCallDelta ¶
type OpenAIChatToolCallDelta struct {
Index *int `json:"index,omitempty"`
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Function OpenAIChatToolCallFunctionDelta `json:"function"`
}
type OpenAIChatToolFunction ¶
type OpenAIChatUsage ¶
type OpenAIChatUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
PromptCacheHitTokens int `json:"prompt_cache_hit_tokens"`
PromptTokensDetails OpenAIChatPromptTokenDetails `json:"prompt_tokens_details"`
CompletionTokenDetails OpenAIChatCompletionTokenDetails `json:"completion_tokens_details"`
}
type OpenAICodexProcessOptions ¶
type OpenAICodexProcessOptions struct {
ServiceTier string
}
type OpenAICodexResponsesPayload ¶
type OpenAICodexResponsesPayload struct {
Model string `json:"model"`
Store bool `json:"store"`
Stream bool `json:"stream"`
Instructions string `json:"instructions"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Input []OpenAIResponsesInputItem `json:"input,omitempty"`
Tools []OpenAIResponsesTool `json:"tools,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Reasoning map[string]string `json:"reasoning,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Text map[string]string `json:"text,omitempty"`
Include []string `json:"include,omitempty"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
ToolChoice string `json:"tool_choice,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls"`
}
func BuildOpenAICodexResponsesPayload ¶
func BuildOpenAICodexResponsesPayload(model Model, context Context, options OpenAICodexResponsesPayloadOptions) OpenAICodexResponsesPayload
type OpenAICodexResponsesProvider ¶
type OpenAICodexResponsesProvider struct {
Client HTTPDoer
Now func() time.Time
Sleep func(context.Context, time.Duration) error
}
func NewOpenAICodexResponsesProvider ¶
func NewOpenAICodexResponsesProvider(client HTTPDoer) OpenAICodexResponsesProvider
func (OpenAICodexResponsesProvider) Stream ¶
func (p OpenAICodexResponsesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (OpenAICodexResponsesProvider) StreamSimple ¶
func (p OpenAICodexResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type OpenAICodexWebSocketDebugStats ¶
type OpenAICodexWebSocketDebugStats struct {
Requests int `json:"requests"`
ConnectionsCreated int `json:"connectionsCreated"`
ConnectionsReused int `json:"connectionsReused"`
CachedContextRequests int `json:"cachedContextRequests"`
StoreTrueRequests int `json:"storeTrueRequests"`
FullContextRequests int `json:"fullContextRequests"`
DeltaRequests int `json:"deltaRequests"`
LastInputItems int `json:"lastInputItems"`
LastDeltaInputItems *int `json:"lastDeltaInputItems,omitempty"`
LastPreviousResponseID string `json:"lastPreviousResponseId,omitempty"`
WebSocketFailures int `json:"websocketFailures"`
SSEFallbacks int `json:"sseFallbacks"`
WebSocketFallbackActive bool `json:"websocketFallbackActive,omitempty"`
LastWebSocketError string `json:"lastWebSocketError,omitempty"`
}
func GetOpenAICodexWebSocketDebugStats ¶
func GetOpenAICodexWebSocketDebugStats(sessionID string) (OpenAICodexWebSocketDebugStats, bool)
type OpenAICompletionsCompat ¶
type OpenAICompletionsCompat struct {
SupportsDeveloperRole bool
SupportsStore bool
SupportsReasoningEffort bool
SupportsUsageInStreaming bool
SupportsStrictMode bool
SupportsLongCacheRetention bool
MaxTokensField string
ThinkingFormat string
CacheControlFormat string
ZAIToolStream bool
RequiresToolResultName bool
RequiresAssistantAfterToolResult bool
RequiresThinkingAsText bool
RequiresReasoningContentOnAssistant bool
RequiresReasoningContentOnAssistantTurns bool
}
func ResolveOpenAICompletionsCompat ¶
func ResolveOpenAICompletionsCompat(model Model) OpenAICompletionsCompat
type OpenAICompletionsPayload ¶
type OpenAICompletionsPayload struct {
Model string `json:"model"`
Messages []OpenAIChatMessage `json:"messages"`
Stream bool `json:"stream"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
PromptCacheRetention string `json:"prompt_cache_retention,omitempty"`
StreamOptions map[string]any `json:"stream_options,omitempty"`
Store *bool `json:"store,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Tools []OpenAIChatTool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
ToolStream *bool `json:"tool_stream,omitempty"`
EnableThinking *bool `json:"enable_thinking,omitempty"`
ChatTemplateKwargs map[string]any `json:"chat_template_kwargs,omitempty"`
Thinking map[string]any `json:"thinking,omitempty"`
Reasoning map[string]any `json:"reasoning,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
}
func BuildOpenAICompletionsPayload ¶
func BuildOpenAICompletionsPayload(model Model, context Context, options OpenAICompletionsPayloadOptions) OpenAICompletionsPayload
func BuildOpenAICompletionsPayloadChecked ¶
func BuildOpenAICompletionsPayloadChecked(model Model, context Context, options OpenAICompletionsPayloadOptions) (OpenAICompletionsPayload, error)
type OpenAICompletionsProvider ¶
type OpenAICompletionsProvider struct {
Client HTTPDoer
}
func NewOpenAICompletionsProvider ¶
func NewOpenAICompletionsProvider(client HTTPDoer) OpenAICompletionsProvider
func (OpenAICompletionsProvider) Stream ¶
func (p OpenAICompletionsProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (OpenAICompletionsProvider) StreamSimple ¶
func (p OpenAICompletionsProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type OpenAICompletionsStreamProcessor ¶
type OpenAICompletionsStreamProcessor struct {
// contains filtered or unexported fields
}
func NewOpenAICompletionsStreamProcessor ¶
func NewOpenAICompletionsStreamProcessor(model Model, output *Message) *OpenAICompletionsStreamProcessor
func (*OpenAICompletionsStreamProcessor) Process ¶
func (p *OpenAICompletionsStreamProcessor) Process(chunk *OpenAIChatCompletionChunk) []AssistantMessageEvent
func (*OpenAICompletionsStreamProcessor) Result ¶
func (p *OpenAICompletionsStreamProcessor) Result() Message
type OpenAIResponsesCompat ¶
func ResolveOpenAIResponsesCompat ¶
func ResolveOpenAIResponsesCompat(model Model) OpenAIResponsesCompat
type OpenAIResponsesIncompleteDetails ¶
type OpenAIResponsesIncompleteDetails struct {
Reason string
}
type OpenAIResponsesInputItem ¶
type OpenAIResponsesInputItem struct {
Type string `json:"type,omitempty"`
Role string `json:"role,omitempty"`
Content any `json:"content,omitempty"`
Summary []OpenAIResponsesContentPart `json:"summary,omitempty"`
ID string `json:"id,omitempty"`
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Output any `json:"output,omitempty"`
Status string `json:"status,omitempty"`
Phase string `json:"phase,omitempty"`
EncryptedContent string `json:"encrypted_content,omitempty"`
}
func ConvertOpenAIResponsesMessages ¶
func ConvertOpenAIResponsesMessages(model Model, context Context, options ConvertOpenAIResponsesOptions) []OpenAIResponsesInputItem
type OpenAIResponsesOutputItem ¶
type OpenAIResponsesOutputItem struct {
Type string `json:"type,omitempty"`
ID string `json:"id,omitempty"`
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Status string `json:"status,omitempty"`
Content []OpenAIResponsesOutputContentPart `json:"content,omitempty"`
Summary []OpenAIResponsesOutputContentPart `json:"summary,omitempty"`
Phase string `json:"phase,omitempty"`
EncryptedContent string `json:"encrypted_content,omitempty"`
}
type OpenAIResponsesPayload ¶
type OpenAIResponsesPayload struct {
Model string `json:"model"`
Input []OpenAIResponsesInputItem `json:"input"`
Stream bool `json:"stream"`
PromptCacheKey string `json:"prompt_cache_key,omitempty"`
PromptCacheRetention string `json:"prompt_cache_retention,omitempty"`
Store bool `json:"store"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Tools []OpenAIResponsesTool `json:"tools,omitempty"`
Reasoning map[string]string `json:"reasoning,omitempty"`
Include []string `json:"include,omitempty"`
}
func BuildOpenAIResponsesPayload ¶
func BuildOpenAIResponsesPayload(model Model, context Context, options OpenAIResponsesPayloadOptions) OpenAIResponsesPayload
func BuildOpenAIResponsesPayloadChecked ¶
func BuildOpenAIResponsesPayloadChecked(model Model, context Context, options OpenAIResponsesPayloadOptions) (OpenAIResponsesPayload, error)
type OpenAIResponsesProvider ¶
type OpenAIResponsesProvider struct {
Client HTTPDoer
}
func NewOpenAIResponsesProvider ¶
func NewOpenAIResponsesProvider(client HTTPDoer) OpenAIResponsesProvider
func (OpenAIResponsesProvider) Stream ¶
func (p OpenAIResponsesProvider) Stream(model Model, llmContext Context, options StreamOptions) (*AssistantMessageEventStream, error)
func (OpenAIResponsesProvider) StreamSimple ¶
func (p OpenAIResponsesProvider) StreamSimple(model Model, llmContext Context, options SimpleStreamOptions) (*AssistantMessageEventStream, error)
type OpenAIResponsesResponseEvent ¶
type OpenAIResponsesResponseEvent struct {
ID string
Status string
ServiceTier string
Usage *OpenAIResponsesUsage
IncompleteDetails *OpenAIResponsesIncompleteDetails
}
type OpenAIResponsesStreamEvent ¶
type OpenAIResponsesStreamEvent struct {
Type string
Response *OpenAIResponsesResponseEvent
Item *OpenAIResponsesOutputItem
Part *OpenAIResponsesOutputContentPart
Delta string
Arguments string
Error string
}
func DecodeOpenAIResponsesSSEEvent ¶
func DecodeOpenAIResponsesSSEEvent(data []byte) (OpenAIResponsesStreamEvent, error)
type OpenAIResponsesStreamProcessor ¶
type OpenAIResponsesStreamProcessor struct {
// contains filtered or unexported fields
}
func NewOpenAIResponsesStreamProcessor ¶
func NewOpenAIResponsesStreamProcessor(model Model, output *Message) *OpenAIResponsesStreamProcessor
func (*OpenAIResponsesStreamProcessor) Process ¶
func (p *OpenAIResponsesStreamProcessor) Process(event OpenAIResponsesStreamEvent) []AssistantMessageEvent
type OpenAIResponsesTool ¶
type OpenAIResponsesTool struct {
Type string `json:"type"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
Strict *bool `json:"strict,omitempty"`
}
func ConvertOpenAIResponsesTools ¶
func ConvertOpenAIResponsesTools(tools []Tool, strict bool) []OpenAIResponsesTool
type OpenAIResponsesUsage ¶
type OpenAIResponsesUsage struct {
InputTokens int
OutputTokens int
TotalTokens int
InputTokensDetails OpenAIResponsesInputTokenDetails
}
type OpenRouterGeneratedImage ¶
type OpenRouterGeneratedImage struct {
ImageURL any `json:"image_url"`
}
type OpenRouterImagesChoice ¶
type OpenRouterImagesChoice struct {
Message OpenRouterImagesChoiceMessage `json:"message"`
}
type OpenRouterImagesChoiceMessage ¶
type OpenRouterImagesChoiceMessage struct {
Content string `json:"content,omitempty"`
Images []OpenRouterGeneratedImage `json:"images,omitempty"`
}
type OpenRouterImagesContentPart ¶
type OpenRouterImagesContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *OpenRouterImagesImageURL `json:"image_url,omitempty"`
}
type OpenRouterImagesImageURL ¶
type OpenRouterImagesImageURL struct {
URL string `json:"url"`
}
type OpenRouterImagesMessage ¶
type OpenRouterImagesMessage struct {
Role string `json:"role"`
Content []OpenRouterImagesContentPart `json:"content"`
}
type OpenRouterImagesPayload ¶
type OpenRouterImagesPayload struct {
Model string `json:"model"`
Messages []OpenRouterImagesMessage `json:"messages"`
Stream bool `json:"stream"`
Modalities []string `json:"modalities"`
}
func BuildOpenRouterImagesPayload ¶
func BuildOpenRouterImagesPayload(model ImagesModel, imagesContext ImagesContext) OpenRouterImagesPayload
type OpenRouterImagesProvider ¶
type OpenRouterImagesProvider struct {
Client HTTPDoer
}
func NewOpenRouterImagesProvider ¶
func NewOpenRouterImagesProvider(client HTTPDoer) OpenRouterImagesProvider
func (OpenRouterImagesProvider) GenerateImages ¶
func (p OpenRouterImagesProvider) GenerateImages(model ImagesModel, imagesContext ImagesContext, options ImagesOptions) (AssistantImages, error)
type OpenRouterImagesResponse ¶
type OpenRouterImagesResponse struct {
ID string `json:"id"`
Usage *OpenRouterImagesUsage `json:"usage,omitempty"`
Choices []OpenRouterImagesChoice `json:"choices"`
}
type OpenRouterImagesUsage ¶
type OpenRouterImagesUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
PromptTokensDetails OpenRouterPromptTokensDetails `json:"prompt_tokens_details"`
}
type Schema ¶
type Schema struct {
Type any `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Default any `json:"default,omitempty"`
Properties map[string]Schema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Items *Schema `json:"items,omitempty"`
Enum []any `json:"enum,omitempty"`
}
func StringEnum ¶
func StringEnumWithOptions ¶
func StringEnumWithOptions(values []string, options StringEnumOptions) Schema
type SessionResourceCleanup ¶
type SessionResourceCleanupError ¶
type SessionResourceCleanupError struct {
Errors []error
}
func (SessionResourceCleanupError) Error ¶
func (e SessionResourceCleanupError) Error() string
func (SessionResourceCleanupError) Unwrap ¶
func (e SessionResourceCleanupError) Unwrap() []error
type SimpleStreamOptions ¶
type SimpleStreamOptions = StreamOptions
type StreamOptions ¶
type StreamOptions struct {
Context context.Context
Temperature *float64
MaxTokens int
APIKey string
Transport string
CacheRetention string
SessionID string
Reasoning string
ThinkingBudgets map[string]int
Headers map[string]string
TimeoutMillis int
MaxRetries int
MaxRetryDelayMs int
Metadata map[string]any
OnPayload func(payload any, model Model) (any, bool, error)
OnResponseStatus func(status int, headers map[string]string, model Model) error
}
type StringEnumOptions ¶
type Usage ¶
type Usage struct {
Input int `json:"input"`
Output int `json:"output"`
CacheRead int `json:"cacheRead"`
CacheWrite int `json:"cacheWrite"`
TotalTokens int `json:"totalTokens"`
Cost UsageCost `json:"cost"`
}
func EmptyUsage ¶
func EmptyUsage() Usage
func ParseGoogleUsage ¶
func ParseGoogleUsage(raw GoogleUsageMetadata, model Model) Usage
func ParseMistralUsage ¶
func ParseMistralUsage(raw MistralUsage, model Model) Usage
func ParseOpenAIChatUsage ¶
func ParseOpenAIChatUsage(raw OpenAIChatUsage, model Model) Usage
func ParseOpenAIResponsesUsage ¶
func ParseOpenAIResponsesUsage(raw OpenAIResponsesUsage, model Model) Usage
func ParseOpenRouterImagesUsage ¶
func ParseOpenRouterImagesUsage(raw OpenRouterImagesUsage, model ImagesModel) Usage
Source Files
¶
- abort_usage.go
- anthropic_payload.go
- anthropic_provider.go
- anthropic_stream.go
- azure_config.go
- azure_provider.go
- bedrock_config.go
- bedrock_payload.go
- bedrock_stream.go
- cloudflare.go
- diagnostics.go
- env.go
- event_stream.go
- faux.go
- github_copilot_headers.go
- google_convert.go
- google_provider.go
- google_vertex_config.go
- http_provider.go
- http_proxy.go
- image_models.go
- images.go
- message_transform.go
- mistral_payload.go
- mistral_provider.go
- models.go
- oauth.go
- oauth_page.go
- openai_codex.go
- openai_codex_provider.go
- openai_completions_convert.go
- openai_completions_provider.go
- openai_completions_stream.go
- openai_responses_convert.go
- openai_responses_payload.go
- openai_responses_provider.go
- openai_responses_stream.go
- openrouter_images.go
- openrouter_images_provider.go
- overflow.go
- pi_models_generated.go
- registry.go
- session_resources.go
- types.go
- validation.go
Click to show internal directories.
Click to hide internal directories.