package main type MessageRole string const ( RoleSystem MessageRole = "system" RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" RoleTool MessageRole = "tool" ) type Message struct { Role MessageRole `json:"role"` Content string `json:"content"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` } type ToolCall struct { ID string `json:"id"` Type string `json:"type"` Function ToolCallFunction `json:"function"` } type ToolCallFunction struct { Name string `json:"name"` Arguments string `json:"arguments"` } type CacheDef struct { TTL int `yaml:"ttl"` Keys []string `yaml:"keys"` } type AgentDef struct { Name string `yaml:"name"` Description string `yaml:"description"` Type string `yaml:"type"` Cache *CacheDef `yaml:"cache,omitempty"` Tools []string `yaml:"tools"` SystemPrompt string } type Schema map[string]any type ToolDef struct { Name string Description string Parameters Schema Execute func(args map[string]interface{}) (string, error) } type OpenAIMessage struct { Role string `json:"role"` Content *string `json:"content"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` } type OpenAIChoice struct { Index int `json:"index"` Message OpenAIMessage `json:"message"` FinishReason string `json:"finish_reason"` } type OpenAIUsage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } type OpenAIResponse struct { ID string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` Model string `json:"model"` Choices []OpenAIChoice `json:"choices"` Usage OpenAIUsage `json:"usage"` } type OpenAIErrorResponse struct { Error OpenAIError `json:"error"` } type OpenAIError struct { Message string `json:"message"` Type string `json:"type"` Code string `json:"code"` } type OpenAITool struct { Type string `json:"type"` Function OpenAIToolFunc `json:"function"` } type OpenAIToolFunc struct { Name string `json:"name"` Description string `json:"description"` Parameters interface{} `json:"parameters"` }