package domain import ( "context" "time" ) type Chat struct { ID string `db:"id" json:"id"` TeamID string `db:"team_id" json:"teamId"` StartDatetime *time.Time `db:"start_datetime" json:"startDatetime"` EndDatetime *time.Time `db:"end_datetime" json:"endDatetime"` AgentID string `db:"agent_id" json:"agentId"` UserID string `db:"user_id" json:"userId"` TaskID string `db:"task_id" json:"taskId,omitempty"` Title string `db:"title" json:"title"` DateCreated time.Time `db:"_date_created" json:"_date_created"` DateUpdated *time.Time `db:"_date_updated" json:"_date_updated"` VersionId string `db:"_version" json:"_version"` } type Message struct { ID string `db:"id" json:"id"` TeamID string `db:"team_id" json:"teamId"` ChatID string `db:"chat_id" json:"chatId"` Role string `db:"role" json:"role"` Content string `db:"content" json:"content"` ToolCallID string `db:"tool_call_id" json:"toolCallId"` ToolCalls []ToolCall `db:"-" json:"toolcalls"` ToolCallsJson string `db:"tool_calls" json:"-"` DateCreated time.Time `db:"_date_created" json:"_date_created"` DateUpdated *time.Time `db:"_date_updated" json:"_date_updated"` VersionId string `db:"_version" json:"_version"` } type ChatWithMessages struct { Chat *Chat `json:"chat"` Messages []*Message `json:"messages"` } type ChatParams struct { ProviderID string ModelID string OnChunk StreamCallback } type Tool struct { } type ToolCall struct { } type Chunk struct { Done bool `json:"done"` Role string `json:"role"` Content string `json:"content"` Reasoning bool } type StreamCallback func(chunk *Chunk) type Role string const ( RoleSystem Role = "system" RoleUser Role = "user" RoleAssistant Role = "assistant" RoleTool Role = "tool" ) type LLMParams struct { Tools []*Tool OnChunk StreamCallback ReasoningEffort string } type LLMEngine interface { ListProviderTypes() []Item ListModelsFromProvider(ctx context.Context, provider *Provider) ([]string, error) Stream( ctx context.Context, provider *Provider, modelID string, params *LLMParams, messages []*Message, ) (*Message, error) } type ChatRepository interface { ListChats(userID string, teamID string, page int) ([]*Chat, error) GetChat(userID string, teamID string, id string) (*Chat, error) CreateChat(userID string, chat *Chat) (*Chat, error) UpdateChat(userID string, chat *Chat) (*Chat, error) DeleteChat(userID string, teamID string, id string) error GetChatMessages(userID string, teamID string, id string) ([]*Message, error) CreateChatMessage(userID string, message *Message) (*Message, error) }