types

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Messages               []Message
	Tools                  []ToolDefinition
	ThinkingEffort         string
	PreviousResponseID     string // OpenAI specific
	WebSearch              bool
	StructuredOutputs      bool
	StructuredOutputSchema json.RawMessage
}

type ChatResponse

type ChatResponse struct {
	ID                 string
	Text               string
	Model              string
	ToolCalls          []ToolCall
	PreviousResponseID string
	TokenUsage         TokenUsage
}

type LLMProvider

type LLMProvider interface {
	Chat(ctx context.Context, model string, request *ChatRequest) (ChatResponse, error)
	ValidateModel(ctx context.Context, model string) error
	CalculateCost(model string, inputTokens, outputTokens, cachedTokens int64) int64
	EstimateInputTokens(model string, messages []Message) (int, error)
	CheckContextWindow(model string, totalInputTokens int, compactionPercentage int) error
}

type Message

type Message struct {
	Role       MessageRole // Who sent the message
	Content    string      // The text or payload of the message
	Name       string      // Optional: tool name or function name
	ToolCallID string      // Optional: maps back to the provider's call identifier
	ToolCall   *ToolCall   // Optional: captures assistant-issued tool calls
}

Message is a provider-agnostic representation of a single chat turn or tool result.

func NewAssistantMessage

func NewAssistantMessage(content string) *Message

NewAssistantMessage creates an assistant role message with given content.

func NewAssistantToolCallMessage

func NewAssistantToolCallMessage(toolCall ToolCall) *Message

NewAssistantToolCallMessage records a tool call emitted by the assistant.

func NewMessage

func NewMessage(role MessageRole, content string) *Message

func NewSystemMessage

func NewSystemMessage(content string) *Message

NewSystemMessage creates a system role message with given content.

func NewToolMessage

func NewToolMessage(toolName, toolCallID, content string) *Message

NewToolMessage creates a tool role message, including tool name and call ID.

func NewUserMessage

func NewUserMessage(content string) *Message

NewUserMessage creates a user role message with given content.

type MessageRole

type MessageRole string

MessageRole represents the role of a message in the conversation.

const (
	// MessageRoleSystem is used for system-level instructions.
	MessageRoleSystem MessageRole = "system"
	// MessageRoleUser is used for user-originated messages.
	MessageRoleUser MessageRole = "user"
	// MessageRoleAssistant is used for assistant (model) responses.
	MessageRoleAssistant MessageRole = "assistant"
	// MessageRoleTool is used for messages coming from tool executions.
	MessageRoleTool MessageRole = "tool"
)

type ReasoningEffort

type ReasoningEffort string
const (
	ReasoningEffortHigh   ReasoningEffort = "high"
	ReasoningEffortMedium ReasoningEffort = "medium"
	ReasoningEffortLow    ReasoningEffort = "low"
)

func (ReasoningEffort) MarshalJSON

func (e ReasoningEffort) MarshalJSON() ([]byte, error)

func (*ReasoningEffort) UnmarshalJSON

func (e *ReasoningEffort) UnmarshalJSON(b []byte) error

func (ReasoningEffort) Validate

func (e ReasoningEffort) Validate() error

type TokenUsage

type TokenUsage struct {
	InputTokens           int64 `json:"input_tokens"`
	OutputTokens          int64 `json:"output_tokens"`
	CacheReadInputTokens  int64 `json:"cache_read_input_tokens,omitempty"`
	CacheWriteInputTokens int64 `json:"cache_write_input_tokens,omitempty"`
}

type ToolCall

type ToolCall struct {
	Name          string          // tool name the model asked for
	CallID        string          // call id to echo back when submitting results
	Arguments     string          // raw JSON string the model returned
	JSONArguments json.RawMessage // same as arguments but handy for re-marshaling
}

func (*ToolCall) CommandString

func (tc *ToolCall) CommandString() string

type ToolDefinition

type ToolDefinition struct {
	Name        string
	Description string
	JSONSchema  map[string]any `bun:"-"`
}

Jump to

Keyboard shortcuts

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