package ai import "context" // Message represents a single message in a conversation. type Message struct { Role string `json:"role"` // "system", "user", "assistant", "tool" Content string `json:"content"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` Name string `json:"name,omitempty"` } // ToolCall represents a function call requested by the model. type ToolCall struct { ID string `json:"id"` Function struct { Name string `json:"name"` Arguments string `json:"arguments"` } `json:"function"` } // Tool describes a tool available to the model. type Tool struct { Name string `json:"name"` Description string `json:"description"` Parameters map[string]interface{} `json:"parameters"` } // Response is the result from a provider. type Response struct { Content string `json:"content"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` Model string `json:"model"` Usage Usage `json:"usage"` } // Usage tracks token usage. type Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` TotalTokens int `json:"total_tokens"` } // StreamChunk is a piece of a streamed response. type StreamChunk struct { Content string `json:"content,omitempty"` ToolCalls []ToolCall `json:"tool_calls,omitempty"` Done bool `json:"done"` Error error `json:"-"` } // Provider is the interface that all AI backends must implement. type Provider interface { // Chat sends messages and returns a complete response. Chat(ctx context.Context, messages []Message, tools []Tool) (*Response, error) // StreamChat sends messages and returns a channel of streamed chunks. StreamChat(ctx context.Context, messages []Message, tools []Tool) (<-chan StreamChunk, error) // Name returns the provider's display name. Name() string // Models returns the list of available model names. Models() []string }