Documentation
¶
Overview ¶
Package structs 定义存储层的数据结构与 GORM 模型
包含消息、会话、代理等核心业务实体的数据库映射
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Tables = []any{ &Chats{}, &Messages{}, &SubAgents{}, &Terminals{}, &Scopes{}, &Configs{}, &Traces{}, &ReferFiles{}, &ClassifySegment{}, }
Tables 所有表
Functions ¶
This section is empty.
Types ¶
type Chats ¶
type Chats struct {
ID uint32 `gorm:"primaryKey;autoIncrement"`
LastModelID uint32
NowAgent string
Root string
TraceID uint64
State state.State
Title string
ReasoningEffort string
Stop bool `gorm:"-" json:"-"`
DB *gorm.DB `gorm:"-" json:"-"`
CurrentAgentID string `gorm:"-" json:"-"`
CurrentAgentConfig structs.AgentConfig `gorm:"-" json:"-"`
CurrentActivatePath string `gorm:"-" json:"-"`
EnableScopes map[string]bool `gorm:"-" json:"-"`
TemporyDataOfRequest map[string]any `gorm:"-" json:"-"`
TemporyDataOfSession map[string]any `gorm:"-" json:"-"`
InTestFlag bool `gorm:"-" json:"-"`
ReferCount int32 `gorm:"-" json:"-"`
ToolCallingContext map[string]any `gorm:"-" json:"-"`
ToolCallingType map[string]string `gorm:"-" json:"-"`
CurrentToolID string `gorm:"-" json:"-"`
CurrentMessageID uint64 `gorm:"-" json:"-"`
ToolState uint64 `gorm:"-" json:"-"`
LatestToolCallingContext map[string]any `gorm:"-" json:"-"`
LatestToolCallingType map[string]string `gorm:"-" json:"-"`
// ToolKillFn 由当前正在执行的工具注册,loop.Stop() 调用它来中断工具
ToolKillFn func() `gorm:"-" json:"-"`
// contains filtered or unexported fields
}
Chats 对话列表
func (*Chats) GetContext ¶ added in v0.2.8
GetContext 线程安全地获取会话上下文,如果未设置则返回 background
func (*Chats) KillTool ¶ added in v0.2.10
func (c *Chats) KillTool()
KillTool 调用当前工具注册的停止函数(如果有)。 由 loop.Stop() 调用,用于中断正在执行的工具。
func (*Chats) SetContext ¶ added in v0.2.8
SetContext 线程安全地设置会话上下文
func (*Chats) SetToolKillFn ¶ added in v0.2.10
func (c *Chats) SetToolKillFn(fn func())
SetToolKillFn 注册一个函数,用于在 Stop() 被调用时中断当前正在执行的工具。 工具在自己的执行开始时调用此方法注册自己的停止逻辑(如杀死进程), 执行结束后调用 SetToolKillFn(nil) 清理。 每个工具可以定义"不同的stop"——这是给所有工具统一的中断入口。
type ClassifySegment ¶ added in v0.3.0
type ClassifySegment struct {
ID uint64 `gorm:"primaryKey;autoIncrement"`
ChatID uint32 `gorm:"index"`
MessageID uint64 `gorm:"index"`
Label string `gorm:"type:text"`
Text string `gorm:"type:text"`
TempPath string `gorm:"type:text"`
}
ClassifySegment 分类段信息表 记录用户消息经 prompt 分类器分割后的每个段的标签信息。 prompt: 自然语言指令,log: 日志/堆栈,code: 代码片段
type Messages ¶
type Messages struct {
ID uint64 `gorm:"primaryKey;autoIncrement"`
ChatID uint32
AgentID *string
Delta string `gorm:"type:text"`
Summary string `gorm:"type:text"`
ThinkingDelta string `gorm:"type:text"`
Chats *Chats `gorm:"foreignKey:ChatID;constraints:OnDelete:RESTRICT;OnUpdate:CASCADE"`
// SubAgents SubAgents `gorm:"foreignKey:AgentID;constraints:OnDelete:RESTRICT;OnUpdate:CASCADE"`
Refers MessagesReferList `gorm:"type:bytes;serialize:gob"`
ToolCallingJSONString string `gorm:"type:text"`
// ToolFinished bool `gorm:"default:false"`
Time uint64 `gorm:"autoCreateTime"`
ModelName string
ModelID uint32
Type MessagesRole
PromptTokens uint32
CompletionTokens uint32
TotalTokens uint32
CachedTokens uint32
}
Messages 消息列表
type MessagesRefer ¶
type MessagesRefer struct {
FilePath string
FileType MessagesReferType
FileFromLine int32
FileFromCol int32
FileToLine int32
FileToCol int32
Origin []byte
}
MessagesRefer 消息引用
type MessagesReferList ¶
type MessagesReferList []MessagesRefer
MessagesReferList 消息引用
func (*MessagesReferList) Scan ¶
func (m *MessagesReferList) Scan(src any) error
Scan 实现 sql.Scanner 接口,用于 GORM 从数据库读取
type MessagesReferType ¶
type MessagesReferType uint8
MessagesReferType 消息引用类型
const ( MessagesReferTypeFile MessagesReferType = iota MessagesReferTypeText MessagesReferTypeImage )
消息引用类型
type MessagesRole ¶
type MessagesRole uint8
MessagesRole 消息类型
const ( MessagesRoleUser MessagesRole = iota MessagesRoleAgent MessagesRoleTool MessagesRoleCommunicate )
消息引用类型
type ReferFiles ¶
type ReferFiles struct {
ChatID uint32 `gorm:"primaryKey"`
Path string `gorm:"primaryKey"`
Content string `gorm:"type:text"`
ReadOnly bool
Chats Chats `gorm:"foreignKey:ChatID;constraints:OnDelete:RESTRICT;OnUpdate:CASCADE"`
}
ReferFiles 引用的文件列表
type Scopes ¶
type Scopes struct {
ChatID uint32 `gorm:"primaryKey;column:chat_id"`
Name string `gorm:"primaryKey;column:name"`
Enabled bool `gorm:"column:enabled"`
Chats *Chats `gorm:"foreignKey:ChatID;references:ID"`
}
Scopes 存储命名空间启用状态
type SubAgents ¶
type SubAgents struct {
ID string `gorm:"primaryKey"`
// ChatID uint32
AgentID string
BindPath string
Deleted bool
LastSummary string
}
SubAgents 子 agents 列表