Documentation
¶
Index ¶
- type AgnoError
- func NewAPIError(message string, cause error) *AgnoError
- func NewCancellationError(message string, cause error) *AgnoError
- func NewContentModerationError(message string, cause error) *AgnoError
- func NewError(code ErrorCode, message string, cause error) *AgnoError
- func NewInputCheckError(message string, cause error) *AgnoError
- func NewInvalidConfigError(message string, cause error) *AgnoError
- func NewInvalidInputError(message string, cause error) *AgnoError
- func NewModelTimeoutError(message string, cause error) *AgnoError
- func NewOutputCheckError(message string, cause error) *AgnoError
- func NewPIIDetectedError(message string, cause error) *AgnoError
- func NewPromptInjectionError(message string, cause error) *AgnoError
- func NewRateLimitError(message string, cause error) *AgnoError
- func NewToolExecutionError(message string, cause error) *AgnoError
- type ErrorCode
- type Message
- type Metadata
- type ModelResponse
- type ReasoningContent
- type ResponseChunk
- type Role
- type ToolCall
- type ToolCallFunction
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgnoError ¶
AgnoError represents a structured error in the Agno system
func NewAPIError ¶
NewAPIError creates an API error
func NewCancellationError ¶
NewCancellationError creates a cancellation error when a run is cancelled.
func NewContentModerationError ¶
NewContentModerationError creates a content moderation error
func NewInputCheckError ¶
NewInputCheckError creates an input validation check error
func NewInvalidConfigError ¶
NewInvalidConfigError creates an invalid config error
func NewInvalidInputError ¶
NewInvalidInputError creates an invalid input error
func NewModelTimeoutError ¶
NewModelTimeoutError creates a model timeout error
func NewOutputCheckError ¶
NewOutputCheckError creates an output validation check error
func NewPIIDetectedError ¶
NewPIIDetectedError creates a PII detection error
func NewPromptInjectionError ¶
NewPromptInjectionError creates a prompt injection detection error
func NewRateLimitError ¶
NewRateLimitError creates a rate limit error
func NewToolExecutionError ¶
NewToolExecutionError creates a tool execution error
type ErrorCode ¶
type ErrorCode string
ErrorCode represents different types of errors in the system
const ( ErrCodeModelTimeout ErrorCode = "MODEL_TIMEOUT" ErrCodeToolExecution ErrorCode = "TOOL_ERROR" ErrCodeInvalidInput ErrorCode = "INVALID_INPUT" ErrCodeInvalidConfig ErrorCode = "INVALID_CONFIG" ErrCodeAPIError ErrorCode = "API_ERROR" ErrCodeRateLimitError ErrorCode = "RATE_LIMIT" ErrCodeInputCheck ErrorCode = "INPUT_CHECK" ErrCodeOutputCheck ErrorCode = "OUTPUT_CHECK" ErrCodePromptInjection ErrorCode = "PROMPT_INJECTION" ErrCodePIIDetected ErrorCode = "PII_DETECTED" ErrCodeContentModeration ErrorCode = "CONTENT_MODERATION" ErrCodeCancelled ErrorCode = "RUN_CANCELLED" ErrCodeUnknown ErrorCode = "UNKNOWN" )
type Message ¶
type Message struct {
ID string `json:"id"`
Role Role `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
// ReasoningContent 包含模型的推理过程(仅推理模型)
// ReasoningContent contains the model's reasoning process (reasoning models only)
ReasoningContent *ReasoningContent `json:"reasoning_content,omitempty"`
}
Message represents a conversation message
func NewAssistantMessage ¶
NewAssistantMessage creates an assistant message
func NewMessage ¶
NewMessage creates a new message with the given role and content
func NewSystemMessage ¶
NewSystemMessage creates a system message
func NewToolMessage ¶
NewToolMessage creates a tool response message
func NewUserMessage ¶
NewUserMessage creates a user message
type Metadata ¶
type Metadata struct {
FinishReason string `json:"finish_reason,omitempty"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
Metadata contains additional response metadata
type ModelResponse ¶
type ModelResponse struct {
ID string `json:"id,omitempty"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Usage Usage `json:"usage,omitempty"`
Model string `json:"model,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
// ReasoningContent 包含模型的推理过程(仅推理模型)
// ReasoningContent contains the model's reasoning process (reasoning models only)
ReasoningContent *ReasoningContent `json:"reasoning_content,omitempty"`
}
ModelResponse represents the response from a language model
func (*ModelResponse) HasToolCalls ¶
func (r *ModelResponse) HasToolCalls() bool
HasToolCalls checks if the response contains tool calls
func (*ModelResponse) IsEmpty ¶
func (r *ModelResponse) IsEmpty() bool
IsEmpty checks if the response is empty
type ReasoningContent ¶
type ReasoningContent struct {
// Content 是完整的推理内容
// Content is the full reasoning content
Content string `json:"content"`
// RedactedContent 是脱敏后的推理内容(可选)
// RedactedContent is the redacted version of reasoning (optional)
RedactedContent *string `json:"redacted_content,omitempty"`
// TokenCount 是推理内容的 token 数量(可选)
// TokenCount is the number of tokens in reasoning (optional)
TokenCount *int `json:"token_count,omitempty"`
}
ReasoningContent 表示模型的推理内容 ReasoningContent represents the model's reasoning process
func NewReasoningContent ¶
func NewReasoningContent(content string) *ReasoningContent
NewReasoningContent 创建一个新的 ReasoningContent NewReasoningContent creates a new ReasoningContent
func (*ReasoningContent) WithRedacted ¶
func (r *ReasoningContent) WithRedacted(redacted string) *ReasoningContent
WithRedacted 设置脱敏内容 WithRedacted sets the redacted content
func (*ReasoningContent) WithTokenCount ¶
func (r *ReasoningContent) WithTokenCount(count int) *ReasoningContent
WithTokenCount 设置 token 数量 WithTokenCount sets the token count
type ResponseChunk ¶
type ResponseChunk struct {
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Done bool `json:"done"`
Error error `json:"error,omitempty"`
}
ResponseChunk represents a streaming response chunk
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"` // typically "function"
Function ToolCallFunction `json:"function"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
ToolCall represents a tool invocation request from the model
type ToolCallFunction ¶
type ToolCallFunction struct {
Name string `json:"name"`
Arguments string `json:"arguments"` // JSON string
}
ToolCallFunction contains the function call details