types

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgnoError

type AgnoError struct {
	Code    ErrorCode
	Message string
	Cause   error
}

AgnoError represents a structured error in the Agno system

func NewAPIError

func NewAPIError(message string, cause error) *AgnoError

NewAPIError creates an API error

func NewCancellationError

func NewCancellationError(message string, cause error) *AgnoError

NewCancellationError creates a cancellation error when a run is cancelled.

func NewContentModerationError

func NewContentModerationError(message string, cause error) *AgnoError

NewContentModerationError creates a content moderation error

func NewError

func NewError(code ErrorCode, message string, cause error) *AgnoError

NewError creates a new AgnoError

func NewInputCheckError

func NewInputCheckError(message string, cause error) *AgnoError

NewInputCheckError creates an input validation check error

func NewInvalidConfigError

func NewInvalidConfigError(message string, cause error) *AgnoError

NewInvalidConfigError creates an invalid config error

func NewInvalidInputError

func NewInvalidInputError(message string, cause error) *AgnoError

NewInvalidInputError creates an invalid input error

func NewModelTimeoutError

func NewModelTimeoutError(message string, cause error) *AgnoError

NewModelTimeoutError creates a model timeout error

func NewOutputCheckError

func NewOutputCheckError(message string, cause error) *AgnoError

NewOutputCheckError creates an output validation check error

func NewPIIDetectedError

func NewPIIDetectedError(message string, cause error) *AgnoError

NewPIIDetectedError creates a PII detection error

func NewPromptInjectionError

func NewPromptInjectionError(message string, cause error) *AgnoError

NewPromptInjectionError creates a prompt injection detection error

func NewRateLimitError

func NewRateLimitError(message string, cause error) *AgnoError

NewRateLimitError creates a rate limit error

func NewToolExecutionError

func NewToolExecutionError(message string, cause error) *AgnoError

NewToolExecutionError creates a tool execution error

func (*AgnoError) Error

func (e *AgnoError) Error() string

Error implements the error interface

func (*AgnoError) Unwrap

func (e *AgnoError) Unwrap() error

Unwrap returns the underlying cause

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

func NewAssistantMessage(content string) *Message

NewAssistantMessage creates an assistant message

func NewMessage

func NewMessage(role Role, content string) *Message

NewMessage creates a new message with the given role and content

func NewSystemMessage

func NewSystemMessage(content string) *Message

NewSystemMessage creates a system message

func NewToolMessage

func NewToolMessage(toolCallID, content string) *Message

NewToolMessage creates a tool response message

func NewUserMessage

func NewUserMessage(content string) *Message

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 Role

type Role string

Role represents the role of a message sender

const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

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

type Usage

type Usage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

Usage contains token usage information

Jump to

Keyboard shortcuts

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