types

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RoleUser      = "user"
	RoleAssistant = "assistant"
	RoleSystem    = "system"
)

Role constants for messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Role    string // "user", "assistant", or "system"
	Content string // The message content
}

Message represents a single message in a conversation.

type Response

type Response struct {
	// Content is the text response from the AI.
	Content string

	// ToolCalls are any tool invocations requested by the AI.
	ToolCalls []ToolCall

	// StopReason indicates why the model stopped generating.
	StopReason StopReason

	// Usage contains token usage information from the API.
	Usage *Usage
}

Response represents an AI response that may include tool calls.

type StopReason

type StopReason string

StopReason indicates why the model stopped generating.

const (
	// StopReasonEndTurn indicates the model naturally finished its response.
	StopReasonEndTurn StopReason = "end_turn"

	// StopReasonToolUse indicates the model wants to use a tool.
	StopReasonToolUse StopReason = "tool_use"

	// StopReasonMaxTokens indicates the max token limit was reached.
	StopReasonMaxTokens StopReason = "max_tokens"
)

type ToolCall

type ToolCall struct {
	// ID is a unique identifier for this tool call.
	ID string

	// Name is the tool name to execute.
	Name string

	// Input contains the parameters for the tool.
	Input map[string]interface{}
}

ToolCall represents a request from the AI to execute a tool.

type Usage

type Usage struct {
	// InputTokens is the number of tokens in the request/prompt, including tokens read from or written to
	// the prompt cache.
	InputTokens int64

	// OutputTokens is the number of tokens in the response/completion.
	OutputTokens int64

	// TotalTokens is the sum of input and output tokens.
	TotalTokens int64

	// CacheReadTokens is the number of prompt tokens read from prompt cache (if supported).
	// They are included in InputTokens.
	CacheReadTokens int64

	// CacheCreationTokens is the number of prompt tokens written to the prompt cache (if supported).
	// They are included in InputTokens.
	CacheCreationTokens int64
}

Usage contains token usage statistics from the AI provider.

Jump to

Keyboard shortcuts

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