Documentation
¶
Overview ¶
Package chat 提供聊天记录管理和 AI 模型交互功能
Index ¶
- Constants
- Variables
- func AddChatReply(grp int64, txt string)
- func AgentOf(id int64, service string) *goba.Agent
- func CallAgent(ag *goba.Agent, issudo bool, iter int, api deepinfra.API, p model.Protocol, ...) []zero.APIRequest
- func EnsureConfig(ctx *zero.Ctx) bool
- func GetChatContext(p model.Protocol, grp int64, sysp string, isusersys bool) deepinfra.Model
- func NewExtraSetBool[T ~bool](ptr *T) func(ctx *zero.Ctx)
- func NewExtraSetFloat32(ptr *float32) func(ctx *zero.Ctx)
- func NewExtraSetModelType(ptr *ModelType) func(ctx *zero.Ctx)
- func NewExtraSetStr[T ~string](ptr *T) func(ctx *zero.Ctx)
- func NewExtraSetUint(ptr *uint) func(ctx *zero.Ctx)
- func ResetAgents()
- func ResetChat()
- func ResetChatIn(grps ...int64)
- func Sanitize(msg string) string
- type AgentConfig
- type ModelBool
- type ModelKey
- type ModelType
- type Storage
Constants ¶
const ( BitmapRate = 0x0000ff BitmapTemp = 0x00ff00 BitmapNagt = 0x010000 BitmapNrec = 0x020000 BitmapNrat = 0x040000 )
Bitmap constants for storage
Variables ¶
var ( // AtPrefix @用户时给 LLM 的前缀提示, 需要和提示词一致 AtPrefix = ">>" // NameL 包裹用户名的左括号, 需要和提示词一致 NameL = "【" // NameR 包裹用户名的右括号, 需要和提示词一致 NameR = "】" )
var AgentChar []byte
AgentChar 将 char.yaml 内容嵌入为默认 agent 性格
var IsAgentCharReady = false
IsAgentCharReady then logev works
var SystemPrompt string
SystemPrompt 将 README.md 内容嵌入为默认系统提示词
Functions ¶
func CallAgent ¶
func CallAgent(ag *goba.Agent, issudo bool, iter int, api deepinfra.API, p model.Protocol, grp int64, role goba.PermRole) []zero.APIRequest
CallAgent and check group API permission
func EnsureConfig ¶
EnsureConfig ensures the configuration is loaded and valid
func GetChatContext ¶
GetChatContext 根据聊天记录构造可执行的 deepinfra 模型请求
func NewExtraSetBool ¶
NewExtraSetBool creates a handler to set a boolean-based extra config value
func NewExtraSetFloat32 ¶
NewExtraSetFloat32 creates a handler to set a float32 extra config value
func NewExtraSetModelType ¶
NewExtraSetModelType creates a handler to set a ModelType extra config value
func NewExtraSetStr ¶
NewExtraSetStr creates a handler to set a string-based extra config value
func NewExtraSetUint ¶
NewExtraSetUint creates a handler to set a uint extra config value
Types ¶
type AgentConfig ¶
type AgentConfig struct {
ModelName string
ImageModelName string
AgentModelName string
Type ModelType
ImageType ModelType
AgentType ModelType
MaxN uint
TopP float32
SystemP string
AgentChar string
API string
ImageAPI string
AgentAPI string
Key ModelKey
ImageKey ModelKey
AgentKey ModelKey
Separator string
NoSystemP ModelBool
}
AgentConfig holds the configuration for the chat agent
var AC AgentConfig
AC is the global agent configuration
func (*AgentConfig) MParams ¶
func (c *AgentConfig) MParams() (topp float32, maxn uint)
MParams returns the global model parameters: TopP and MaxN
func (*AgentConfig) String ¶
func (c *AgentConfig) String() string
type ModelType ¶
type ModelType int
ModelType 支持打印 string 并生产 protocal
type Storage ¶
Storage wraps ctxext.Storage for chat-specific storage operations
func NewStorage ¶
NewStorage creates a new Storage instance