Documentation ¶
Index ¶
- type AssistantMessage
- type BaseMessage
- type ConvertMessage
- type FunctionCall
- type FunctionTool
- type Input
- type LLM
- type LLMSupportType
- type 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(name, content string, FnList []*FunctionCall) *AssistantMessage
type BaseMessage ¶
type BaseMessage struct { Content string // contains filtered or unexported fields }
func (*BaseMessage) MsgContent ¶
func (im *BaseMessage) MsgContent() string
func (*BaseMessage) MsgRoleName ¶
func (im *BaseMessage) MsgRoleName() string
func (*BaseMessage) MsgType ¶
func (im *BaseMessage) MsgType() MessageType
type ConvertMessage ¶
func ConvertOutput2Message ¶
func ConvertOutput2Message(o *Output) ConvertMessage
func ConvertPrompt2Message ¶
func ConvertPrompt2Message(msgType MessageType, roleName string, pt prompt.Prompt, pm utils.ParamsManager) ConvertMessage
func ConvertString2Message ¶
func ConvertString2Message(msgType MessageType, roleName string, msg string) 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 Input ¶
type Input interface { SetSysMsg(name, content string) GetSysMsg() *SystemMessage Push(fn ConvertMessage) error GetMessage() []Message LastMsg() Message Next() Input }
type LLMSupportType ¶ added in v0.0.2
type LLMSupportType int
const (
LLMSupportTypeTool LLMSupportType = 1 // 消息为系统类型
)
type Message ¶
type Message interface { MsgType() MessageType MsgContent() string }
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 ¶
func NewSystemMessage ¶
func NewSystemMessage(name, content string) *SystemMessage
func (*SystemMessage) MsgContent ¶
func (im *SystemMessage) MsgContent() string
func (*SystemMessage) MsgType ¶
func (im *SystemMessage) MsgType() MessageType
type TokenUsage ¶
type TokenUsage struct { Prompt, Completion, Total int64 }
type ToolFunctionExample ¶
type UserMessage ¶
type UserMessage struct {
BaseMessage
}
func NewUserMessage ¶
func NewUserMessage(name, content string) *UserMessage
Click to show internal directories.
Click to hide internal directories.