52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package domain
|
|
|
|
import "context"
|
|
|
|
// Message represents a single message in the conversation
|
|
type Message struct {
|
|
Role string `json:"role"` // "system", "user", "assistant", "tool"
|
|
Content string `json:"content"` // Message content
|
|
ToolCallID string `json:"tool_call_id,omitempty"` // For tool responses
|
|
ToolCalls []ToolCall `json:"tool_calls,omitempty"` // For assistant messages with function calls
|
|
}
|
|
|
|
// ToolCall represents a function call request from the LLM
|
|
type ToolCall struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"` // "function"
|
|
Function struct {
|
|
Name string `json:"name"`
|
|
Arguments string `json:"arguments"` // JSON string
|
|
} `json:"function"`
|
|
}
|
|
|
|
// Tool represents a function available to the LLM
|
|
type Tool struct {
|
|
Type string `json:"type"` // "function"
|
|
Function ToolFunction `json:"function"`
|
|
}
|
|
|
|
// ToolFunction defines a function that can be called
|
|
type ToolFunction struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Parameters map[string]interface{} `json:"parameters"`
|
|
}
|
|
|
|
// LLMRequest represents a request to the LLM with conversation history
|
|
type LLMRequest struct {
|
|
Messages []Message `json:"messages"`
|
|
Tools []Tool `json:"tools,omitempty"`
|
|
}
|
|
|
|
// LLMResponse represents the response from the LLM
|
|
type LLMResponse struct {
|
|
Content string `json:"content"`
|
|
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
|
}
|
|
|
|
// LLMProvider defines the interface for LLM providers
|
|
type LLMProvider interface {
|
|
Complete(ctx context.Context, request LLMRequest) (*LLMResponse, error)
|
|
}
|