basic llm request stream
This commit is contained in:
1 parent
f74e4d1043
commit
a92cc76a9a
66 files changed
+1496
-158
No files matched your search
@@ -1,32 +1,47 @@
|
||||
package domain
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type LLMModelDetail struct {
|
||||
ParentModel string `json:"parent_model"`
|
||||
Format string `json:"format"`
|
||||
Family string `json:"family"`
|
||||
Families []string `json:"families"`
|
||||
ParameterSize string `json:"parameter_size"`
|
||||
QuantizationLevel string `json:"quantization_level"`
|
||||
}
|
||||
|
||||
type LLMModel struct {
|
||||
Name string `json:"name"`
|
||||
Model string `json:"model"`
|
||||
ModifiedAt int64 `json:"modified_at"`
|
||||
Size int64 `json:"size"`
|
||||
Digest string `json:"digest"`
|
||||
Detail *LLMModelDetail `json:"detail"`
|
||||
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 {
|
||||
Role string
|
||||
Content string
|
||||
ToolCalls []ToolCall
|
||||
ToolCallID string
|
||||
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"`
|
||||
}
|
||||
|
||||
//Reasoning *Reasoning
|
||||
type ChatWithMessages struct {
|
||||
Chat *Chat `json:"chat"`
|
||||
Messages []*Message `json:"messages"`
|
||||
}
|
||||
|
||||
type ChatParams struct {
|
||||
ProviderID string
|
||||
ModelID string
|
||||
OnChunk StreamCallback
|
||||
}
|
||||
|
||||
type Tool struct {
|
||||
@@ -36,14 +51,13 @@ type ToolCall struct {
|
||||
}
|
||||
|
||||
type Chunk struct {
|
||||
Content string
|
||||
Done bool `json:"done"`
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
Reasoning bool
|
||||
}
|
||||
|
||||
type StreamParams struct {
|
||||
Tools []*Tool
|
||||
OnChunk func(chunk *Chunk)
|
||||
OnDebug func()
|
||||
}
|
||||
type StreamCallback func(chunk *Chunk)
|
||||
|
||||
type Role string
|
||||
|
||||
@@ -54,6 +68,12 @@ const (
|
||||
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)
|
||||
@@ -61,7 +81,17 @@ type LLMEngine interface {
|
||||
ctx context.Context,
|
||||
provider *Provider,
|
||||
modelID string,
|
||||
params *StreamParams,
|
||||
params *LLMParams,
|
||||
messages []*Message,
|
||||
) error
|
||||
) (*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)
|
||||
}
|
||||
Reference in new issue
Block a user