Documentation
¶
Overview ¶
Package openai constructs native ADK models for OpenAI-compatible endpoints.
Index ¶
- func New(ctx context.Context, cfg Config) (model.LLM, error)
- func RawChatToolResult(value any) (map[string]any, error)
- type ChatError
- type ChatErrorKind
- type ChatTokenLimitDialect
- type Config
- type Protocol
- type ProtocolUnavailableError
- type RequestError
- type RequestFailure
- type ResponseTooLargeError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RawChatToolResult ¶ added in v0.1.2
RawChatToolResult marks a JSON-compatible value for direct Chat Completions conversion or a bounded one-shot run. Responses and durable session persistence are unsupported and fail serialization closed.
Types ¶
type ChatError ¶
type ChatError struct {
Kind ChatErrorKind
}
ChatError reports a Chat Completions compatibility failure without wire data.
type ChatErrorKind ¶
type ChatErrorKind string
ChatErrorKind identifies a stable Chat Completions compatibility failure.
const ( ChatErrorDuplicateToolCallID ChatErrorKind = "duplicate_tool_call_id" ChatErrorEmptyChoices ChatErrorKind = "empty_choices" ChatErrorInvalidToolResult ChatErrorKind = "invalid_tool_result" ChatErrorMalformedArguments ChatErrorKind = "malformed_arguments" ChatErrorMissingFunctionName ChatErrorKind = "missing_function_name" ChatErrorMultipleChoices ChatErrorKind = "multiple_choices" ChatErrorNilRequest ChatErrorKind = "nil_request" ChatErrorUnsupportedContent ChatErrorKind = "unsupported_content" ChatErrorUnsupportedStreaming ChatErrorKind = "unsupported_streaming" ChatErrorUnsupportedToolCall ChatErrorKind = "unsupported_tool_call" )
type ChatTokenLimitDialect ¶
type ChatTokenLimitDialect string
ChatTokenLimitDialect selects the Chat Completions output-token field.
const ( // ChatTokenLimitMaxTokens sends ADK MaxOutputTokens as max_tokens. ChatTokenLimitMaxTokens ChatTokenLimitDialect = "max_tokens" // ChatTokenLimitMaxCompletionTokens sends ADK MaxOutputTokens as max_completion_tokens. ChatTokenLimitMaxCompletionTokens ChatTokenLimitDialect = "max_completion_tokens" )
type Config ¶
type Config struct {
Protocol Protocol
Model string
BaseURL string
APIKey string
HTTPClient *http.Client
MaxResponseBytes int64
MaxRetries int
ChatTokenLimit ChatTokenLimitDialect
}
Config contains the complete OpenAI model construction contract.
type Protocol ¶
type Protocol string
Protocol selects the fixed OpenAI wire protocol used by a model.
type ProtocolUnavailableError ¶
type ProtocolUnavailableError struct {
}
ProtocolUnavailableError reports a recognized protocol whose implementation is not present.
func (*ProtocolUnavailableError) Error ¶
func (err *ProtocolUnavailableError) Error() string
type RequestError ¶
type RequestError struct {
Failure RequestFailure
StatusCode int
// contains filtered or unexported fields
}
RequestError reports a request failure without exposing provider, endpoint, or body text.
func (*RequestError) Error ¶
func (err *RequestError) Error() string
func (*RequestError) Is ¶
func (err *RequestError) Is(target error) bool
Is preserves matching for caller-owned transport and redirect-policy sentinels.
type RequestFailure ¶
type RequestFailure string
RequestFailure classifies a redacted model request error.
const ( // RequestFailureTransport identifies a caller HTTP policy or transport failure. RequestFailureTransport RequestFailure = "transport" // RequestFailureProvider identifies an HTTP error response from the provider. RequestFailureProvider RequestFailure = "provider" // RequestFailureResponse identifies an invalid or unreadable provider response. RequestFailureResponse RequestFailure = "response" )
type ResponseTooLargeError ¶
type ResponseTooLargeError struct {
Limit int64
}
ResponseTooLargeError reports a decompressed response that crossed its configured limit.
func (*ResponseTooLargeError) Error ¶
func (err *ResponseTooLargeError) Error() string
func (*ResponseTooLargeError) Is ¶
func (err *ResponseTooLargeError) Is(target error) bool
Is allows errors.Is to classify all oversized OpenAI responses.
type ValidationError ¶
type ValidationError struct {
Field string
}
ValidationError reports one invalid construction field without including its value.
func (*ValidationError) Error ¶
func (err *ValidationError) Error() string