Documentation ¶
Index ¶
- type AssistantMessage
- type BaseMessage
- type ConvertMessage
- type FunctionCall
- type FunctionTool
- type Input
- type LLM
- type LLMSupportType
- type Message
- func ConvertOutput2Message(o *Output) []Message
- func ConvertPrompt2Message(msgType MessageType, roleName string, pm utils.ParamsManager, pt prompt.Prompt) (Message, error)
- func ConvertPromptArray2Message(msgType MessageType, roleName string, pm utils.ParamsManager, ...) ([]Message, error)
- func ConvertString2Message(msgType MessageType, roleName string, msg string) Message
- func ConvertStringArray2Message(msgType MessageType, roleName string, msgs ...string) []Message
- type MessageType
- type Output
- type OutputFinishType
- type OutputMsg
- type SystemMessage
- type TokenUsage
- type Tool
- type ToolBox
- type ToolFunctionExample
- type ToolType
- type UserMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssistantMessage ¶
type AssistantMessage struct { BaseMessage FnList []*FunctionCall }
func NewAssistantMessage ¶
func NewAssistantMessage(role, content string, FnList []*FunctionCall) *AssistantMessage
type BaseMessage ¶
type BaseMessage struct {
// contains filtered or unexported fields
}
func (*BaseMessage) Content ¶
func (im *BaseMessage) Content() string
func (*BaseMessage) Role ¶ added in v0.0.9
func (im *BaseMessage) Role() string
func (*BaseMessage) Type ¶ added in v0.0.9
func (im *BaseMessage) Type() MessageType
type ConvertMessage ¶
type FunctionCall ¶
type FunctionCall struct { ID, Name, Arguments, Result string }
type FunctionTool ¶
type FunctionTool struct {
// contains filtered or unexported fields
}
func NewFuncTool ¶
func NewFuncTool(name, desc string, fn interface{}, example ...ToolFunctionExample) (*FunctionTool, error)
func (*FunctionTool) Desc ¶
func (t *FunctionTool) Desc() string
func (*FunctionTool) Examples ¶
func (t *FunctionTool) Examples() []ToolFunctionExample
func (*FunctionTool) Name ¶
func (t *FunctionTool) Name() string
func (*FunctionTool) ParamJsonScheme ¶
func (t *FunctionTool) ParamJsonScheme() (string, error)
func (*FunctionTool) Type ¶
func (t *FunctionTool) Type() ToolType
type LLMSupportType ¶ added in v0.0.2
type LLMSupportType int
const (
LLMSupportTypeTool LLMSupportType = 1 // 消息为系统类型
)
type Message ¶
type Message interface { Type() MessageType Content() string Role() string }
func ConvertOutput2Message ¶
func ConvertPrompt2Message ¶
func ConvertPrompt2Message(msgType MessageType, roleName string, pm utils.ParamsManager, pt prompt.Prompt) (Message, error)
func ConvertPromptArray2Message ¶ added in v0.0.9
func ConvertPromptArray2Message(msgType MessageType, roleName string, pm utils.ParamsManager, pts ...prompt.Prompt) ([]Message, error)
func ConvertString2Message ¶
func ConvertString2Message(msgType MessageType, roleName string, msg string) Message
func ConvertStringArray2Message ¶ added in v0.0.9
func ConvertStringArray2Message(msgType MessageType, roleName string, msgs ...string) []Message
type MessageType ¶
type MessageType int
const ( MessageTypeInvalid MessageType = 0 MessageTypeSystem MessageType = 1 // 消息为系统类型 MessageTypeUser MessageType = 2 // 消息为用户类型 MessageTypeAssistant MessageType = 3 // 消息为对话助手类型 MessageLimit = 100 )
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func NewOutput ¶
func NewOutput(usage TokenUsage, content []*OutputMsg) *Output
func (*Output) GetCurrUsage ¶
func (o *Output) GetCurrUsage() TokenUsage
func (*Output) GetTotalUsage ¶
func (o *Output) GetTotalUsage() TokenUsage
func (*Output) MergeMessage ¶
type OutputFinishType ¶
type OutputFinishType int
const ( OutputFinishInvalid OutputFinishType = 0 OutputFinishNormal OutputFinishType = 1 // 输出内容完全由大模型生成,未触发截断、替换 OutputFinishStop OutputFinishType = 2 // 输出结果命中入参 stop 中指定的字段后被截断 OutputFinishLength OutputFinishType = 3 // 达到了最大的 token 数 OutputFinishContentFilter OutputFinishType = 4 // 输出内容被截断、兜底、替换为**等 OutputFinishToolCalls OutputFinishType = 5 // 调用了 tool call 功能 )
type OutputMsg ¶
type OutputMsg struct {
// contains filtered or unexported fields
}
func NewOutputMsg ¶
func NewOutputMsg(msgType MessageType, name, content string, finishReason OutputFinishType, fnList ...*FunctionCall) *OutputMsg
func (*OutputMsg) FinishReason ¶
func (om *OutputMsg) FinishReason() OutputFinishType
func (*OutputMsg) FunctionCallList ¶
func (om *OutputMsg) FunctionCallList() []FunctionCall
func (*OutputMsg) MsgType ¶
func (om *OutputMsg) MsgType() MessageType
type SystemMessage ¶
type SystemMessage struct {
BaseMessage
}
func NewSystemMessage ¶
func NewSystemMessage(role, content string) *SystemMessage
type TokenUsage ¶
type TokenUsage struct { Prompt, Completion, Total int64 }
type ToolFunctionExample ¶
type UserMessage ¶
type UserMessage struct {
BaseMessage
}
func NewUserMessage ¶
func NewUserMessage(role, content string) *UserMessage
Click to show internal directories.
Click to hide internal directories.