Documentation
¶
Overview ¶
Package ai_sdk @Author Clover @Data 2024/8/12 下午4:13:00 @Desc 返回错误类
Package ai_sdk @Author Clover @Data 2024/8/11 下午10:34:00 @Desc openapi 客户端
Package ai_sdk @Author Clover @Data 2024/8/12 下午4:33:00 @Desc 自定义错误
Package ai_sdk @Author Clover @Data 2024/8/11 下午10:34:00 @Desc 多会话管理器
Package ai_sdk @Author Clover @Data 2024/8/12 下午4:00:00 @Desc 函数调用注册 todo 设计函数调用外部注册
Package ai_sdk @Author Clover @Data 2024/8/11 下午10:48:00 @Desc gpt实体类 request
Package ai_sdk @Author Clover @Data 2024/8/11 下午10:48:00 @Desc
Index ¶
- Constants
- type AIClient
- type BaseResponse
- type CallFunc
- type ChatCompletionRequest
- type Choice
- type DefalutResponse
- type Delta
- type FuncCallInfo
- type FuncCallRegister
- type FuncInfoNameList
- type Function
- type FunctionCall
- type FunctionCallResponse
- type FunctionParameter
- type Message
- type Properties
- type Property
- type Request
- type RespError
- type Response
- type Ret
- type Session
- func (s *Session) AddPreset(addedpreset string)
- func (s *Session) GetSession(sessionId string, extraOp func() string) *sessionInfo
- func (s *Session) IsExist(sessionId string) bool
- func (s *Session) ResetPreset(preset string)
- func (s *Session) TalkById(sessionId string, content string) (string, error)
- func (s *Session) TalkByIdEx(sessionId string, content string, extraOp func() string) (string, error)
- type StreamOptions
- type Tool
- type ToolCall
- type Usage
Constants ¶
const (
ToolsCallFinishReason = "tool_calls" // 方法调用
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIClient ¶
type AIClient struct { ContentType string Model string ApiCfgList []config.APIConfig EndPoint string // contains filtered or unexported fields }
func NewAIClient ¶
func NewAIClient(apiCfgList []config.APIConfig, model string, endPoint string, timeout int) *AIClient
NewAIClient 创建一个自定义请求客户端
func (AIClient) Send ¶
func (a AIClient) Send(req Request) (resp Response[DefalutResponse], err error)
func (AIClient) SendByFuncCall ¶
func (a AIClient) SendByFuncCall(req Request) (resp Response[FunctionCallResponse], err error)
SendByFuncCall 使用 Send默认调用就可以支持 Function_Call deprecated
type BaseResponse ¶
func (BaseResponse) Err ¶
func (b BaseResponse) Err() error
func (BaseResponse) Ok ¶
func (b BaseResponse) Ok() bool
type ChatCompletionRequest ¶
type DefalutResponse ¶
type FuncCallInfo ¶ added in v0.3.0
type FuncCallInfo struct { Function // 方法信息 CallFunc // 外部函数 CustomTrigger func(content string) bool }
func (*FuncCallInfo) Call ¶ added in v0.3.0
func (fc *FuncCallInfo) Call(callId string, params string) (Message, error)
Call 调用方法
func (*FuncCallInfo) IsCall ¶ added in v0.3.0
func (fc *FuncCallInfo) IsCall(content string) bool
type FuncCallRegister ¶ added in v0.3.0
type FuncCallRegister struct { Name2Info map[string]*FuncCallInfo // contains filtered or unexported fields }
var FuncRegister FuncCallRegister
func (*FuncCallRegister) GetCallInfo ¶ added in v0.3.0
func (fc *FuncCallRegister) GetCallInfo(name string) *FuncCallInfo
GetCallInfo 根据方法名获取方法调用信息
func (*FuncCallRegister) GetToolsByContent ¶ added in v0.3.0
func (fc *FuncCallRegister) GetToolsByContent(content string) *[]Tool
GetToolsByContent 根据触发条件返回调用方法信息
func (*FuncCallRegister) Register ¶ added in v0.3.0
func (fc *FuncCallRegister) Register(finfo *FuncCallInfo, triggerWords []string)
Register 注册调用方法
type FuncInfoNameList ¶ added in v0.3.0
type FuncInfoNameList []string
type Function ¶
type Function struct { Name string `json:"name"` Description string `json:"description"` Parameters FunctionParameter `json:"parameters"` Strict bool `json:"strict"` // 是否严格 JSON 输出 }
Function 定义函数结构
type FunctionCall ¶
type FunctionCallResponse ¶
type FunctionParameter ¶
type FunctionParameter struct { Type string `json:"type"` Properties `json:"properties"` Required []string `json:"required"` }
FunctionParameter 定义函数参数类型
type Properties ¶ added in v0.3.0
type Property ¶
type Property struct { Type string `json:"type"` Description string `json:"description"` Enum []string `json:"enum,omitempty"` // 用于枚举类型的字段 }
Property 定义函数属性类型
type Response ¶
type Response[T any | DefalutResponse | FunctionCallResponse] struct { ID string `json:"id"` Object string `json:"object"` Created int64 `json:"created"` Model string `json:"model"` // contains filtered or unexported fields }
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session 会话主体 (k-v 会话id-会话信息)
var DefaultSession *Session
func NewSession ¶
func (*Session) GetSession ¶
GetSession 获取唯一会话
func (*Session) ResetPreset ¶ added in v0.3.4
ResetPreset 重设预设
type StreamOptions ¶
type StreamOptions struct {
IncludeUsage bool `json:"include_usage,omitempty"`
}
type ToolCall ¶
type ToolCall struct { ID string `json:"id"` Type string `json:"type"` Function FunctionCall `json:"function"` }
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package config @Author Clover @Data 2024/8/12 下午12:53:00 @Desc 配置项
|
Package config @Author Clover @Data 2024/8/12 下午12:53:00 @Desc 配置项 |
example_func_call
|
|
weather
Package weather @Author Clover @Data 2024/8/15 下午5:16:00 @Desc
|
Package weather @Author Clover @Data 2024/8/15 下午5:16:00 @Desc |
Package global @Author Clover @Data 2024/8/15 下午7:06:00 @Desc 方法调用注册器公有字段
|
Package global @Author Clover @Data 2024/8/15 下午7:06:00 @Desc 方法调用注册器公有字段 |
Package logging @Author Clover @Data 2024/7/18 上午10:24:00 @Desc 日志输出
|
Package logging @Author Clover @Data 2024/7/18 上午10:24:00 @Desc 日志输出 |
utils
|
|
configutil
Package configutil @Author Clover @Data 2024/7/6 下午3:51:00 @Desc
|
Package configutil @Author Clover @Data 2024/7/6 下午3:51:00 @Desc |