models

package
v1.68.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheControl added in v1.66.0

type CacheControl struct {
	Type string `json:"type"` // "ephemeral"
}

CacheControl for Anthropic KV cache optimization.

type ContentBlock added in v1.66.0

type ContentBlock struct {
	Type         string        `json:"type"` // "text", "tool_use", "tool_result"
	Text         string        `json:"text,omitempty"`
	CacheControl *CacheControl `json:"cache_control,omitempty"`
}

ContentBlock supports multi-part content (text + tool_use).

type LLMResponse added in v1.66.0

type LLMResponse struct {
	Content    string     `json:"content"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	Usage      *UsageInfo `json:"usage,omitempty"`
	StopReason string     `json:"stop_reason,omitempty"`
}

LLMResponse is the structured response from tool-aware providers.

func (*LLMResponse) HasToolCalls added in v1.66.0

func (r *LLMResponse) HasToolCalls() bool

HasToolCalls returns true if the response contains tool calls.

type Message

type Message struct {
	Role        string         `json:"role"`                   // O papel da mensagem: "user", "assistant", "system", "tool".
	Content     string         `json:"content"`                // O conteúdo da mensagem.
	Meta        *MessageMeta   `json:"meta,omitempty"`         // Optional metadata for history compaction.
	ToolCalls   []ToolCall     `json:"tool_calls,omitempty"`   // Tool calls from assistant (native API).
	ToolCallID  string         `json:"tool_call_id,omitempty"` // ID when this message is a tool result.
	SystemParts []ContentBlock `json:"system_parts,omitempty"` // Structured system prompt parts (for cache control).
}

Message representa uma mensagem trocada com o modelo de linguagem.

func (*Message) IsValid

func (m *Message) IsValid() bool

IsValid valida se a mensagem tem um papel e conteúdo válidos.

type MessageMeta added in v1.65.2

type MessageMeta struct {
	IsSummary bool   `json:"is_summary,omitempty"` // true if this message is a compacted summary
	SummaryOf int    `json:"summary_of,omitempty"` // how many original messages were summarized
	Mode      string `json:"mode,omitempty"`       // "chat", "agent", "coder" — which mode produced this message
}

MessageMeta carries non-content metadata for history management.

type ResponseData

type ResponseData struct {
	Status   string `json:"status"`   // O status da resposta: "processing", "completed", ou "error".
	Response string `json:"response"` // A resposta da LLM, se o status for "completed".
	Message  string `json:"message"`  // Mensagem de erro, se o status for "error".
}

ResponseData representa os dados de resposta da LLM.

func (*ResponseData) IsValid

func (r *ResponseData) IsValid() bool

IsValid valida se o status da resposta é um dos valores esperados.

type SessionData added in v1.65.2

type SessionData struct {
	Version      int       `json:"version"` // 2 for the new format
	ChatHistory  []Message `json:"chat_history"`
	AgentHistory []Message `json:"agent_history,omitempty"`
	CoderHistory []Message `json:"coder_history,omitempty"`
	SharedMemory []Message `json:"shared_memory,omitempty"`
}

SessionData is the v2 session format that supports scoped histories. It is backward-compatible with the legacy format (plain []Message).

type ToolCall added in v1.66.0

type ToolCall struct {
	ID        string                 `json:"id"`
	Type      string                 `json:"type"` // "function"
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments"`
	Raw       string                 `json:"raw,omitempty"` // Original text if parsed from XML
}

ToolCall represents a tool invocation from the LLM response.

func (ToolCall) ArgumentsJSON added in v1.66.0

func (tc ToolCall) ArgumentsJSON() string

ArgumentsJSON returns the arguments as a JSON string.

type ToolDefinition added in v1.66.0

type ToolDefinition struct {
	Type     string          `json:"type"` // "function"
	Function ToolFunctionDef `json:"function"`
}

ToolDefinition describes a tool the LLM can call via native API.

type ToolFunctionDef added in v1.66.0

type ToolFunctionDef struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"parameters"`
}

ToolFunctionDef is the function schema within a tool definition.

type ToolResult added in v1.66.0

type ToolResult struct {
	ToolCallID string `json:"tool_call_id"`
	Content    string `json:"content"`
	IsError    bool   `json:"is_error,omitempty"`
}

ToolResult is sent back after executing a tool.

type UsageInfo added in v1.49.0

type UsageInfo struct {
	PromptTokens     int // Tokens usados no prompt
	CompletionTokens int // Tokens usados na resposta
	TotalTokens      int // Total de tokens usados
}

UsageInfo representa informações de uso de tokens retornadas pelas APIs

Jump to

Keyboard shortcuts

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