Documentation
¶
Overview ¶
Package model defines the shared data types used across the SDK: multi-modal messages, tool calling protocol, and token usage tracking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalToolArgs ¶
MarshalToolArgs marshals arguments to a JSON string suitable for ToolCall.Arguments.
Types ¶
type DataRef ¶
type DataRef struct {
MimeType string `json:"mime_type,omitempty"`
Value map[string]any `json:"value"`
}
DataRef carries structured JSON-compatible data in a message part.
type FileRef ¶
type FileRef struct {
URI string `json:"uri"`
MimeType string `json:"mime_type,omitempty"`
Name string `json:"name,omitempty"`
}
FileRef references a generic file (URI + MIME), e.g. for A2A-style payloads.
type MediaRef ¶
type MediaRef struct {
URL string `json:"url,omitempty"`
Base64 string `json:"base64,omitempty"`
MediaType string `json:"media_type,omitempty"`
}
MediaRef references an image or audio asset.
type Message ¶
Message is a multi-modal, provider-agnostic chat message.
func CloneMessages ¶ added in v0.2.3
CloneMessages returns a deep copy of msgs. Nil stays nil so callers can preserve the usual JSON / len semantics.
func NewImageMessage ¶
NewImageMessage creates a user message with text and an image URL.
func NewTextMessage ¶
NewTextMessage creates a simple text message.
func NewToolCallMessage ¶
NewToolCallMessage creates an assistant message containing tool calls.
func NewToolResultMessage ¶
func NewToolResultMessage(results []ToolResult) Message
NewToolResultMessage creates a tool-role message with multiple results.
func (Message) Clone ¶ added in v0.2.3
Clone returns a deep copy of m. It duplicates the Parts slice and all pointer-backed payloads so callers can safely retain or mutate the result.
func (Message) HasToolCalls ¶
HasToolCalls reports whether the message contains any tool calls.
func (Message) ToolResults ¶
func (m Message) ToolResults() []ToolResult
ToolResults extracts all tool-result parts.
type Part ¶
type Part struct {
Type PartType `json:"type"`
Text string `json:"text,omitempty"`
Image *MediaRef `json:"image,omitempty"`
Audio *MediaRef `json:"audio,omitempty"`
File *FileRef `json:"file,omitempty"`
Data *DataRef `json:"data,omitempty"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
ToolResult *ToolResult `json:"tool_result,omitempty"`
}
Part is a single content unit within a Message.
func CloneParts ¶ added in v0.2.3
CloneParts returns a deep copy of parts.
type StreamChunk ¶
type StreamChunk struct {
Role Role `json:"role,omitempty"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
}
StreamChunk is an incremental piece of a streaming response.
type TokenUsage ¶
type TokenUsage struct {
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
TotalTokens int64 `json:"total_tokens"`
}
TokenUsage tracks cumulative token consumption (includes TotalTokens).
func (TokenUsage) Add ¶
func (u TokenUsage) Add(other TokenUsage) TokenUsage
Add returns a new TokenUsage that is the sum of u and other.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments string `json:"arguments"`
}
ToolCall represents a function call requested by the LLM.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
}
ToolDefinition describes a tool for LLM function-calling.
type ToolResult ¶
type ToolResult struct {
ToolCallID string `json:"tool_call_id"`
Content string `json:"content"`
IsError bool `json:"is_error,omitempty"`
}
ToolResult carries the result of a tool execution back to the LLM.