Documentation
¶
Index ¶
- type ChatRequest
- type ChatResponse
- type LLMProvider
- type Message
- func NewAssistantMessage(content string) *Message
- func NewAssistantToolCallMessage(toolCall ToolCall) *Message
- func NewMessage(role MessageRole, content string) *Message
- func NewSystemMessage(content string) *Message
- func NewToolMessage(toolName, toolCallID, content string) *Message
- func NewUserMessage(content string) *Message
- type MessageRole
- type ReasoningEffort
- type TokenUsage
- type ToolCall
- type ToolDefinition
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 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 ¶
NewAssistantMessage creates an assistant role message with given content.
func NewAssistantToolCallMessage ¶
NewAssistantToolCallMessage records a tool call emitted by the assistant.
func NewMessage ¶
func NewMessage(role MessageRole, content string) *Message
func NewSystemMessage ¶
NewSystemMessage creates a system role message with given content.
func NewToolMessage ¶
NewToolMessage creates a tool role message, including tool name and call ID.
func NewUserMessage ¶
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 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 ¶
Click to show internal directories.
Click to hide internal directories.