57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package domain
|
|
|
|
import "context"
|
|
|
|
// LLMMessage represents a message in the conversation
|
|
type LLMMessage struct {
|
|
Role string `json:"role"`
|
|
Content string `json:"content,omitempty"`
|
|
ToolCallID string `json:"tool_call_id,omitempty"`
|
|
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
|
|
}
|
|
|
|
// ToolCall represents a function call from the LLM
|
|
type ToolCall struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"`
|
|
Function Function `json:"function"`
|
|
}
|
|
|
|
// Function represents the function being called
|
|
type Function struct {
|
|
Name string `json:"name"`
|
|
Arguments string `json:"arguments"`
|
|
}
|
|
|
|
// Tool represents a tool definition for function calling
|
|
type Tool struct {
|
|
Type string `json:"type"`
|
|
Function FunctionDef `json:"function"`
|
|
}
|
|
|
|
// FunctionDef defines a function that can be called
|
|
type FunctionDef struct {
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Parameters interface{} `json:"parameters"`
|
|
}
|
|
|
|
// LLMRequest represents a request to the LLM with function calling support
|
|
type LLMRequest struct {
|
|
Messages []LLMMessage `json:"messages"`
|
|
Tools []Tool `json:"tools,omitempty"`
|
|
ToolChoice string `json:"tool_choice,omitempty"`
|
|
Temperature float64 `json:"temperature,omitempty"`
|
|
}
|
|
|
|
// LLMResponse represents the response from the LLM
|
|
type LLMResponse struct {
|
|
Message LLMMessage `json:"message"`
|
|
FinishReason string `json:"finish_reason"`
|
|
}
|
|
|
|
// LLMProvider defines the interface for LLM providers
|
|
type LLMProvider interface {
|
|
Chat(ctx context.Context, request LLMRequest) (*LLMResponse, error)
|
|
}
|