Files
YunShu/types.go

100 lines
2.4 KiB
Go
Raw Permalink Normal View History

2026-05-08 10:12:31 +08:00
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"`
2026-05-08 10:12:31 +08:00
}
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
2026-05-08 10:12:31 +08:00
}
type Schema map[string]any
2026-05-08 10:12:31 +08:00
type ToolDef struct {
Name string
Description string
Parameters Schema
2026-05-08 10:12:31 +08:00
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"`
}