common

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatResponse

type ChatResponse struct {
	Message       string         `json:"message"`
	Reasoning     string         `json:"reasoning,omitempty"`
	FunctionCalls []FunctionCall `json:"function_calls,omitempty"`
	TokenUsage    *TokenUsage    `json:"token_usage,omitempty"`
}

ChatResponse represents the response from a chat request

type FunctionCall

type FunctionCall struct {
	ID        string                 `json:"id,omitempty"`
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments"`
}

FunctionCall represents a tool/function call

type FunctionResponseData

type FunctionResponseData struct {
	ID       string                 `json:"id"`
	Name     string                 `json:"name"`
	Response map[string]interface{} `json:"response"`
}

FunctionResponseData represents the response to a function call

type Message

type Message struct {
	Role             string                `json:"role"`
	Content          string                `json:"content"`
	ReasoningContent string                `json:"reasoning_content,omitempty"`
	FunctionCalls    []FunctionCall        `json:"function_calls,omitempty"`
	FunctionResponse *FunctionResponseData `json:"function_response,omitempty"`
}

Message represents a chat message

type Provider

type Provider interface {
	// Chat sends a non-streaming chat request
	Chat(messages []Message, tools []Tool, thinkingEnabled bool) (*ChatResponse, error)

	// ChatStream sends a streaming chat request
	ChatStream(messages []Message, tools []Tool, thinkingEnabled bool, callback StreamCallback) (*ChatResponse, error)

	// Close closes any resources
	Close() error
}

Provider represents an LLM provider interface

type ProviderConfig

type ProviderConfig struct {
	Provider string // "claude", "openai", "openrouter", "ollama", "llamacpp"
	APIKey   string
	BaseURL  string // optional override
	Model    string // model name
	Timeout  time.Duration
}

ProviderConfig holds configuration for creating a provider

type StreamCallback

type StreamCallback func(chunk string, isThought bool)

StreamCallback is called for each chunk during streaming

type TokenUsage

type TokenUsage struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
}

TokenUsage represents token usage information

type Tool

type Tool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"input_schema"`
}

Tool represents a tool/function definition

Jump to

Keyboard shortcuts

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