Documentation
¶
Index ¶
- func ConvertToParamValues(model *Model, paramValues []*druntime.ParamConfigValue) map[string]*ParamValue
- func FromDOChatMsgPart(p *ChatMessagePart) schema.ChatMessagePart
- func FromDOChatMsgParts(ps []*ChatMessagePart) []schema.ChatMessagePart
- func FromDOFunctionCall(f *FunctionCall) schema.FunctionCall
- func FromDOImageURL(p *ChatMessageImageURL) *schema.ChatMessageImageURL
- func FromDOMessage(do *Message) *schema.Message
- func FromDOMessages(dos []*Message) []*schema.Message
- func FromDOOptions(options *Options) ([]einoModel.Option, error)
- func FromDOResponseMeta(rm *ResponseMeta) *schema.ResponseMeta
- func FromDOTokenUsage(tu *TokenUsage) *schema.TokenUsage
- func FromDOTool(do *ToolInfo) (*schema.ToolInfo, error)
- func FromDOToolCall(t *ToolCall) schema.ToolCall
- func FromDOToolCalls(ts []*ToolCall) []schema.ToolCall
- func FromDOToolChoice(do ToolChoice) (einoToolChoice schema.ToolChoice)
- func FromDOTools(dos []*ToolInfo) ([]*schema.ToolInfo, error)
- func GetImplSpecificOptions[T any](base *T, opts ...Option) *T
- func GetReasoningContent(msg *schema.Message) string
- func MsgToTraceModelChoice(msg *Message) *tracespec.ModelChoice
- func MsgToTraceMsg(m *Message) *tracespec.ModelMessage
- func MsgsToTraceMsgs(ms []*Message) []*tracespec.ModelMessage
- func OptionsToTrace(os []Option) *tracespec.ModelCallOption
- func PartToTraceMessagePart(p *ChatMessagePart) *tracespec.ModelMessagePart
- func PartsToTraceMessageParts(ps []*ChatMessagePart) []*tracespec.ModelMessagePart
- func StreamMsgsToTraceModelChoices(msgs []*Message) *tracespec.ModelOutput
- func ToTraceModelInput(msgs []*Message, ts []*ToolInfo, tc *ToolChoice) *tracespec.ModelInput
- func ToolCallToTraceToolCall(t *ToolCall) *tracespec.ModelToolCall
- func ToolCallsToTraceToolCalls(ts []*ToolCall) []*tracespec.ModelToolCall
- func ToolChoiceToTraceToolChoice(tc *ToolChoice) *tracespec.ModelToolChoice
- func ToolToTraceTool(t *ToolInfo) *tracespec.ModelTool
- func ToolsToTraceTools(ts []*ToolInfo) []*tracespec.ModelTool
- type Ability
- type AbilityEnum
- type AbilityImage
- type AbilityMultiModal
- type ChatMessageImageURL
- type ChatMessagePart
- type ChatMessagePartType
- type CommonParam
- type Family
- type Frame
- type FunctionCall
- type GetModelReq
- type IStreamReader
- type ImageURLDetail
- type ListModelReq
- type ListModelsFilter
- type Message
- type Model
- func (m *Model) Available(scenario *Scenario) bool
- func (m *Model) GetModel() string
- func (m *Model) GetScenarioConfig(scenario *Scenario) *ScenarioConfig
- func (m *Model) SupportFunctionCall() bool
- func (m *Model) SupportImageBinary() (bool, int64, int64)
- func (m *Model) SupportImageURL() (bool, int64)
- func (m *Model) SupportMultiModalInput() bool
- func (m *Model) Valid() error
- type ModelRequestRecord
- type ModelStatus
- type Option
- func WithFrequencyPenalty(f float32) Option
- func WithMaxTokens(m int) Option
- func WithModel(m string) Option
- func WithParamValues(p map[string]*ParamValue) Option
- func WithParameters(p map[string]string) Option
- func WithPresencePenalty(p float32) Option
- func WithResponseFormat(r *ResponseFormat) Option
- func WithStop(s []string) Option
- func WithTemperature(t float32) Option
- func WithToolChoice(t *ToolChoice) Option
- func WithTools(t []*ToolInfo) Option
- func WithTopK(t *int32) Option
- func WithTopP(t float32) Option
- func WrapImplSpecificOptFn[T any](optFn func(*T)) Option
- type Options
- type ParamConfig
- type ParamOption
- type ParamSchema
- type ParamType
- type ParamValue
- type Protocol
- type ProtocolConfig
- type ProtocolConfigArk
- type ProtocolConfigArkBot
- type ProtocolConfigClaude
- type ProtocolConfigDeepSeek
- type ProtocolConfigGemini
- type ProtocolConfigGeminiSafetySetting
- type ProtocolConfigOllama
- type ProtocolConfigOpenAI
- type ProtocolConfigQianfan
- type ProtocolConfigQwen
- type Quota
- type Reaction
- type ResponseFormat
- type ResponseFormatType
- type ResponseMeta
- type Role
- type RuntimeConfig
- type Scenario
- type ScenarioConfig
- type Series
- type StreamReader
- type StreamRespParseResult
- type TokenUsage
- type ToolCall
- type ToolChoice
- type ToolDefType
- type ToolInfo
- type Visibility
- type VisibleMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToParamValues ¶
func ConvertToParamValues(model *Model, paramValues []*druntime.ParamConfigValue) map[string]*ParamValue
func FromDOChatMsgPart ¶
func FromDOChatMsgPart(p *ChatMessagePart) schema.ChatMessagePart
func FromDOChatMsgParts ¶
func FromDOChatMsgParts(ps []*ChatMessagePart) []schema.ChatMessagePart
func FromDOFunctionCall ¶
func FromDOFunctionCall(f *FunctionCall) schema.FunctionCall
func FromDOImageURL ¶
func FromDOImageURL(p *ChatMessageImageURL) *schema.ChatMessageImageURL
func FromDOMessage ¶
func FromDOMessages ¶
func FromDOResponseMeta ¶
func FromDOResponseMeta(rm *ResponseMeta) *schema.ResponseMeta
func FromDOTokenUsage ¶
func FromDOTokenUsage(tu *TokenUsage) *schema.TokenUsage
func FromDOToolCall ¶
func FromDOToolCalls ¶
func FromDOToolChoice ¶
func FromDOToolChoice(do ToolChoice) (einoToolChoice schema.ToolChoice)
func GetImplSpecificOptions ¶
GetImplSpecificOptions extract the implementation specific options from Option list, optionally providing a base options with default values. e.g.
myOption := &MyOption{
Field1: "default_value",
}
myOption := model.GetImplSpecificOptions(myOption, opts...)
func GetReasoningContent ¶
func MsgToTraceModelChoice ¶
func MsgToTraceModelChoice(msg *Message) *tracespec.ModelChoice
func MsgToTraceMsg ¶
func MsgToTraceMsg(m *Message) *tracespec.ModelMessage
func MsgsToTraceMsgs ¶
func MsgsToTraceMsgs(ms []*Message) []*tracespec.ModelMessage
func OptionsToTrace ¶
func OptionsToTrace(os []Option) *tracespec.ModelCallOption
func PartToTraceMessagePart ¶
func PartToTraceMessagePart(p *ChatMessagePart) *tracespec.ModelMessagePart
func PartsToTraceMessageParts ¶
func PartsToTraceMessageParts(ps []*ChatMessagePart) []*tracespec.ModelMessagePart
func StreamMsgsToTraceModelChoices ¶
func StreamMsgsToTraceModelChoices(msgs []*Message) *tracespec.ModelOutput
func ToTraceModelInput ¶
func ToTraceModelInput(msgs []*Message, ts []*ToolInfo, tc *ToolChoice) *tracespec.ModelInput
func ToolCallToTraceToolCall ¶
func ToolCallToTraceToolCall(t *ToolCall) *tracespec.ModelToolCall
func ToolCallsToTraceToolCalls ¶
func ToolCallsToTraceToolCalls(ts []*ToolCall) []*tracespec.ModelToolCall
func ToolChoiceToTraceToolChoice ¶
func ToolChoiceToTraceToolChoice(tc *ToolChoice) *tracespec.ModelToolChoice
func ToolToTraceTool ¶
func ToolsToTraceTools ¶
Types ¶
type Ability ¶
type Ability struct {
MaxContextTokens *int64 `json:"max_context_tokens" yaml:"max_context_tokens" mapstructure:"max_context_tokens"`
MaxInputTokens *int64 `json:"max_input_tokens" yaml:"max_input_tokens" mapstructure:"max_input_tokens"`
MaxOutputTokens *int64 `json:"max_output_tokens" yaml:"max_output_tokens" mapstructure:"max_output_tokens"`
FunctionCall bool `json:"function_call" yaml:"function_call" mapstructure:"function_call"`
JsonMode bool `json:"json_mode" yaml:"json_mode" mapstructure:"json_mode"`
MultiModal bool `json:"multi_modal" yaml:"multi_modal" mapstructure:"multi_modal"`
AbilityMultiModal *AbilityMultiModal `json:"ability_multi_modal" yaml:"ability_multi_modal" mapstructure:"ability_multi_modal"`
Thinking bool `json:"thinking" mapstructure:"thinking"`
}
func (*Ability) GetAbilityEnums ¶
func (a *Ability) GetAbilityEnums() []AbilityEnum
func (*Ability) ValidAbility ¶
type AbilityEnum ¶
type AbilityEnum string
const ( AbilityEnumUndefined AbilityEnum = "undefined" AbilityEnumFunctionCall AbilityEnum = "function_call" AbilityEnumMultiModal AbilityEnum = "multi_modal" AbilityEnumJsonMode AbilityEnum = "json_mode" AbilityEnumThinking AbilityEnum = "thinking" )
type AbilityImage ¶
type AbilityImage struct {
URLEnabled bool `json:"url_enabled" yaml:"url_enabled" mapstructure:"url_enabled"`
BinaryEnabled bool `json:"binary_enabled" yaml:"binary_enabled" mapstructure:"binary_enabled"`
MaxImageSize int64 `json:"max_image_size" yaml:"max_image_size" mapstructure:"max_image_size"`
MaxImageCount int64 `json:"max_image_count" yaml:"max_image_count" mapstructure:"max_image_count"`
}
type AbilityMultiModal ¶
type AbilityMultiModal struct {
Image bool `json:"image" yaml:"image" mapstructure:"image"`
AbilityImage *AbilityImage `json:"ability_image" yaml:"ability_image" mapstructure:"ability_image"`
}
type ChatMessageImageURL ¶
type ChatMessageImageURL struct {
// URL can either be a traditional URL or a special URL conforming to RFC-2397 (https://www.rfc-editor.org/rfc/rfc2397).
// double check with model implementations for detailed instructions on how to use this.
URL string `json:"url,omitempty"`
URI string `json:"uri,omitempty"`
// Detail is the quality of the image url.
Detail ImageURLDetail `json:"detail,omitempty"`
// MIMEType is the mime type of the image, eg. "image/png".
MIMEType string `json:"mime_type,omitempty"`
}
func ToDOImageURL ¶
func ToDOImageURL(cm *schema.ChatMessageImageURL) *ChatMessageImageURL
type ChatMessagePart ¶
type ChatMessagePart struct {
Type ChatMessagePartType `json:"type"`
Text string `json:"text"`
ImageURL *ChatMessageImageURL `json:"image_url"`
}
func ToDOMultiContent ¶
func ToDOMultiContent(cm schema.ChatMessagePart) *ChatMessagePart
func ToDOMultiContents ¶
func ToDOMultiContents(cms []schema.ChatMessagePart) []*ChatMessagePart
func (*ChatMessagePart) IsBinary ¶
func (p *ChatMessagePart) IsBinary() bool
func (*ChatMessagePart) IsMultiModal ¶
func (p *ChatMessagePart) IsMultiModal() bool
func (*ChatMessagePart) IsURL ¶
func (p *ChatMessagePart) IsURL() bool
type ChatMessagePartType ¶
type ChatMessagePartType string
const ( // ChatMessagePartTypeText means the part is a text. ChatMessagePartTypeText ChatMessagePartType = "text" // ChatMessagePartTypeImageURL means the part is an image url. ChatMessagePartTypeImageURL ChatMessagePartType = "image_url" // ChatMessagePartTypeAudioURL means the part is an audio url. ChatMessagePartTypeAudioURL ChatMessagePartType = "audio_url" // ChatMessagePartTypeVideoURL means the part is a video url. ChatMessagePartTypeVideoURL ChatMessagePartType = "video_url" // ChatMessagePartTypeFileURL means the part is a file url. ChatMessagePartTypeFileURL ChatMessagePartType = "file_url" )
type CommonParam ¶
type CommonParam struct {
MaxTokens *int `json:"max_tokens,omitempty" yaml:"max_tokens" mapstructure:"max_tokens"`
Temperature *float32 `json:"temperature,omitempty" yaml:"temperature" mapstructure:"temperature"`
TopP *float32 `json:"top_p,omitempty" yaml:"top_p" mapstructure:"top_p"`
TopK *int `json:"top_k,omitempty" yaml:"top_k" mapstructure:"top_k"`
Stop []string `json:"stop,omitempty" yaml:"stop" mapstructure:"stop"`
FrequencyPenalty *float32 `json:"frequency_penalty,omitempty" yaml:"frequency_penalty" mapstructure:"frequency_penalty"`
PresencePenalty *float32 `json:"presence_penalty,omitempty" yaml:"presence_penalty" mapstructure:"presence_penalty"`
}
type FunctionCall ¶
type FunctionCall struct {
// Name is the name of the function to call, it can be used to identify the specific function.
Name string `json:"name,omitempty"`
// Arguments is the arguments to call the function with, in JSON format.
Arguments string `json:"arguments,omitempty"`
}
FunctionCall is the function call in a message. It's used in Assistant Message.
func ToDOFunctionCall ¶
func ToDOFunctionCall(f schema.FunctionCall) *FunctionCall
type GetModelReq ¶
type IStreamReader ¶
func NewStreamReader ¶
func NewStreamReader(frame Frame, einoReader *schema.StreamReader[*schema.Message]) IStreamReader
type ImageURLDetail ¶
type ImageURLDetail string
ImageURLDetail is the detail of the image url.
const ( // ImageURLDetailHigh means the high quality image url. ImageURLDetailHigh ImageURLDetail = "high" // ImageURLDetailLow means the low quality image url. ImageURLDetailLow ImageURLDetail = "low" // ImageURLDetailAuto means the auto quality image url. ImageURLDetailAuto ImageURLDetail = "auto" )
type ListModelReq ¶
type ListModelsFilter ¶
type ListModelsFilter struct {
NameLike *string `json:"name_like,omitempty"`
Families []Family `json:"families,omitempty"`
ModelStatuses []ModelStatus `json:"model_statuses,omitempty"`
Abilities []AbilityEnum `json:"abilities,omitempty"`
}
type Message ¶
type Message struct {
Role Role `json:"role"`
Content string `json:"content"`
ReasoningContent string `json:"reasoning_content"`
// if MultiModalContent is not empty, use this instead of Content
// if MultiModalContent is empty, use Content
MultiModalContent []*ChatMessagePart `json:"multi_content,omitempty"`
Name string `json:"name,omitempty"`
// only for AssistantMessage
ToolCalls []*ToolCall `json:"tool_calls,omitempty"`
// only for ToolMessage
ToolCallID string `json:"tool_call_id,omitempty"`
ResponseMeta *ResponseMeta `json:"response_meta,omitempty"`
}
func MergeStreamMsgs ¶
func (*Message) GetImageCountAndMaxSize ¶
func (*Message) GetInputToken ¶
func (*Message) GetOutputToken ¶
func (*Message) HasMultiModalContent ¶
type Model ¶
type Model struct {
ID int64 `json:"id" yaml:"id" mapstructure:"id"` // id
WorkspaceID int64 `json:"workspace_id" yaml:"workspace_id" mapstructure:"workspace_id"` // 空间id,to be used in future
Name string `json:"name" yaml:"name" mapstructure:"name"` // 模型展示名称
Desc string `json:"desc" yaml:"desc" mapstructure:"desc"` // 模型描述
Ability *Ability `json:"ability" yaml:"ability" mapstructure:"ability"` // 模型能力
Frame Frame `json:"frame" yaml:"frame" mapstructure:"frame"` // 该模型使用的外部框架,目前只支持eino
Protocol Protocol `json:"protocol" yaml:"protocol" mapstructure:"protocol"` // 该模型的协议类型,如ark/deepseek/openai等
ProtocolConfig *ProtocolConfig `json:"protocol_config" yaml:"protocol_config" mapstructure:"protocol_config"` // 该模型的协议配置
ScenarioConfigs map[Scenario]*ScenarioConfig `json:"scenario_configs" yaml:"scenario_configs" mapstructure:"scenario_configs"` // 该模型的场景配置
ParamConfig *ParamConfig `json:"param_config" yaml:"param_config" mapstructure:"param_config"` // 该模型的参数配置
Identification string `json:"identification" yaml:"identification"`
Series *Series `json:"series" yaml:"series"`
Visibility *Visibility `json:"visibility" yaml:"visibility"`
Icon string `json:"icon" yaml:"icon" mapstructure:"icon"` // 模型图标
Tags []string `json:"tags" yaml:"tags" mapstructure:"tags"` // 模型标签
Status ModelStatus `json:"status" yaml:"status" mapstructure:"status"` // 模型状态
OriginalModelURL string `json:"original_model_url" yaml:"original_model_url" mapstructure:"original_model_url"` // 模型跳转链接
PresetModel bool `json:"preset_model" yaml:"preset_model" mapstructure:"preset_model"` // 是否为预置模型
CreatedBy string `json:"created_by" yaml:"created_by" mapstructure:"created_by"` // 创建人
CreatedAt int64 `json:"created_at" yaml:"created_at" mapstructure:"created_at"` // 创建时间
UpdatedBy string `json:"updated_by" yaml:"updated_by" mapstructure:"updated_by"` // 更新人
UpdatedAt int64 `json:"updated_at" yaml:"updated_at" mapstructure:"updated_at"` // 更新时间
}
func (*Model) GetScenarioConfig ¶
func (m *Model) GetScenarioConfig(scenario *Scenario) *ScenarioConfig
func (*Model) SupportFunctionCall ¶
func (*Model) SupportImageURL ¶
func (*Model) SupportMultiModalInput ¶
type ModelRequestRecord ¶
type ModelRequestRecord struct {
ID int64 `json:"id"`
SpaceID int64 `json:"space_id"`
UserID string `json:"user_id"`
UsageScene Scenario `json:"usage_scene"`
UsageSceneEntityID string `json:"usage_scene_entity_id"`
Frame Frame `json:"frame"`
Protocol Protocol `json:"protocol"`
ModelIdentification string `json:"model_identification"`
ModelAk string `json:"model_ak"`
ModelID string `json:"model_id"`
ModelName string `json:"model_name"`
InputToken int64 `json:"input_token"`
OutputToken int64 `json:"output_token"`
Logid string `json:"logid"`
ErrorCode string `json:"error_code"`
ErrorMsg *string `json:"error_msg"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ModelStatus ¶
type ModelStatus string
const ( ModelStatusUndefined ModelStatus = "undefined" ModelStatusEnabled ModelStatus = "enabled" ModelStatusDisabled ModelStatus = "disabled" )
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func WithFrequencyPenalty ¶
func WithMaxTokens ¶
func WithParamValues ¶
func WithParamValues(p map[string]*ParamValue) Option
func WithParameters ¶
func WithPresencePenalty ¶
func WithResponseFormat ¶
func WithResponseFormat(r *ResponseFormat) Option
func WithTemperature ¶
func WithToolChoice ¶
func WithToolChoice(t *ToolChoice) Option
func WrapImplSpecificOptFn ¶
WrapImplSpecificOptFn is the option to wrap the implementation specific option function.
type Options ¶
type Options struct {
// Temperature is the temperature for the model, which controls the randomness of the model.
Temperature *float32
// MaxTokens is the max number of tokens, if reached the max tokens, the model will stop generating, and mostly return an finish reason of "length".
MaxTokens *int
// Model is the model name.
Model *string
// TopP is the top p for the model, which controls the diversity of the model.
TopP *float32
// Stop is the stop words for the model, which controls the stopping condition of the model.
Stop []string
// Tools is a list of tools the model may call.
Tools []*ToolInfo
// ToolChoice controls which tool is called by the model.
ToolChoice *ToolChoice
// ResponseFormat is the response format for the model. default is text
ResponseFormat *ResponseFormat
// TopK is the top k for the model, which controls the diversity of the model.
TopK *int32
// PresencePenalty is the presence penalty for the model, which controls the diversity of the model.
PresencePenalty *float32
// FrequencyPenalty is the frequency penalty for the model, which controls the diversity of the model.
FrequencyPenalty *float32
// Parameters is the extra parameters for the model.
Parameters map[string]string
// ParamValues
ParamValues map[string]*ParamValue
}
func ApplyOptions ¶
type ParamConfig ¶
type ParamConfig struct {
ParamSchemas []*ParamSchema `json:"param_schemas" yaml:"param_schemas" mapstructure:"param_schemas"`
}
func (*ParamConfig) GetCommonParamDefaultVal ¶
func (p *ParamConfig) GetCommonParamDefaultVal() CommonParam
func (*ParamConfig) GetDefaultVal ¶
func (p *ParamConfig) GetDefaultVal(params []string) map[string]string
type ParamOption ¶
type ParamSchema ¶
type ParamSchema struct {
Name string `json:"name" yaml:"name" mapstructure:"name"`
Label string `json:"label" yaml:"label" mapstructure:"label"`
Desc string `json:"desc" yaml:"desc" mapstructure:"desc"`
Type ParamType `json:"type" yaml:"type" mapstructure:"type"`
Min string `json:"min" yaml:"min" mapstructure:"min"`
Max string `json:"max" yaml:"max" mapstructure:"max"`
DefaultValue string `json:"default_value" yaml:"default_value" mapstructure:"default_value"`
Options []*ParamOption `json:"options" yaml:"options" mapstructure:"options"`
Properties []*ParamSchema `json:"properties" mapstructrue:"properties"`
JsonPath string `json:"json_path" mapstructrue:"json_path"`
Reaction *Reaction `json:"reaction" mapstructrue:"reaction"`
}
type ParamValue ¶
type ParamValue struct {
Name string `json:"name"`
ParamType ParamType `json:"param_type"`
Value string `json:"value"`
JsonPath string `json:"json_path"`
}
func (*ParamValue) GetValue ¶
func (p *ParamValue) GetValue() (any, error)
type Protocol ¶
type Protocol string
const ( ProtocolUndefined Protocol = "undefined" ProtocolArk Protocol = "ark" ProtocolOpenAI Protocol = "openai" ProtocolDeepseek Protocol = "deepseek" ProtocolClaude Protocol = "claude" ProtocolOllama Protocol = "ollama" ProtocolGemini Protocol = "gemini" ProtocolQwen Protocol = "qwen" ProtocolQianfan Protocol = "qianfan" ProtocolArkBot Protocol = "arkbot" )
type ProtocolConfig ¶
type ProtocolConfig struct {
BaseURL string `json:"base_url" yaml:"base_url" mapstructure:"base_url"`
APIKey string `json:"api_key" yaml:"api_key" mapstructure:"api_key"`
Model string `json:"model" yaml:"model" mapstructure:"model"`
TimeoutMs *int64 `json:"timeout_ms" yaml:"timeout_ms" mapstructure:"timeout_ms"`
ProtocolConfigArk *ProtocolConfigArk `json:"protocol_config_ark" yaml:"protocol_config_ark" mapstructure:"protocol_config_ark"`
ProtocolConfigOpenAI *ProtocolConfigOpenAI `json:"protocol_config_openai" yaml:"protocol_config_openai" mapstructure:"protocol_config_openai"`
ProtocolConfigClaude *ProtocolConfigClaude `json:"protocol_config_claude" yaml:"protocol_config_claude" mapstructure:"protocol_config_claude"`
ProtocolConfigDeepSeek *ProtocolConfigDeepSeek `json:"protocol_config_deep_seek" yaml:"protocol_config_deep_seek" mapstructure:"protocol_config_deep_seek"`
ProtocolConfigGemini *ProtocolConfigGemini `json:"protocol_config_gemini" yaml:"protocol_config_gemini" mapstructure:"protocol_config_gemini"`
ProtocolConfigOllama *ProtocolConfigOllama `json:"protocol_config_ollama" yaml:"protocol_config_ollama" mapstructure:"protocol_config_ollama"`
ProtocolConfigQwen *ProtocolConfigQwen `json:"protocol_config_qwen" yaml:"protocol_config_qwen" mapstructure:"protocol_config_qwen"`
ProtocolConfigQianfan *ProtocolConfigQianfan `json:"protocol_config_qianfan" yaml:"protocol_config_qianfan" mapstructure:"protocol_config_qianfan"`
ProtocolConfigArkBot *ProtocolConfigArkBot `json:"protocol_config_ark_bot" yaml:"protocol_config_ark_bot" mapstructure:"protocol_config_ark_bot"`
}
func (*ProtocolConfig) ValidProtocolConfig ¶
func (p *ProtocolConfig) ValidProtocolConfig(protocol Protocol) error
type ProtocolConfigArk ¶
type ProtocolConfigArk struct {
Region string `json:"region" yaml:"region" mapstructure:"region"`
AccessKey string `json:"access_key" yaml:"access_key" mapstructure:"access_key"`
SecretKey string `json:"secret_key" yaml:"secret_key" mapstructure:"secret_key"`
RetryTimes *int64 `json:"retry_times" yaml:"retry_times" mapstructure:"retry_times"`
CustomHeaders map[string]string `json:"custom_headers" yaml:"custom_headers" mapstructure:"custom_headers"`
}
type ProtocolConfigArkBot ¶
type ProtocolConfigArkBot struct {
Region string `json:"region" yaml:"region" mapstructure:"region"`
AccessKey string `json:"access_key" yaml:"access_key" mapstructure:"access_key"`
SecretKey string `json:"secret_key" yaml:"secret_key" mapstructure:"secret_key"`
RetryTimes *int64 `json:"retry_times" yaml:"retry_times" mapstructure:"retry_times"`
CustomHeaders map[string]string `json:"custom_headers" yaml:"custom_headers" mapstructure:"custom_headers"`
}
type ProtocolConfigClaude ¶
type ProtocolConfigClaude struct {
ByBedrock bool `json:"by_bedrock" yaml:"by_bedrock" mapstructure:"by_bedrock"`
AccessKey string `json:"access_key" yaml:"access_key" mapstructure:"access_key"`
SecretAccessKey string `json:"secret_access_key" yaml:"secret_access_key" mapstructure:"secret_access_key"`
SessionToken string `json:"session_token" yaml:"session_token" mapstructure:"session_token"`
Region string `json:"region" yaml:"region" mapstructure:"region"`
}
type ProtocolConfigDeepSeek ¶
type ProtocolConfigDeepSeek struct {
ResponseFormatType string `json:"response_format_type" yaml:"response_format_type" mapstructure:"response_format_type"`
}
type ProtocolConfigGemini ¶
type ProtocolConfigGemini struct {
ResponseSchema *string `json:"response_schema" yaml:"response_schema" mapstructure:"response_schema"`
EnableCodeExecution bool `json:"enable_code_execution" yaml:"enable_code_execution" mapstructure:"enable_code_execution"`
SafetySettings []ProtocolConfigGeminiSafetySetting `json:"safety_settings" yaml:"safety_settings" mapstructure:"safety_settings"`
}
type ProtocolConfigGeminiSafetySetting ¶
type ProtocolConfigGeminiSafetySetting struct {
// Required. The category for this setting.
Category int32 `json:"category" yaml:"category" mapstructure:"category"`
// Required. Controls the probability threshold at which harm is blocked.
Threshold int32 `json:"threshold" yaml:"threshold" mapstructure:"threshold"`
}
type ProtocolConfigOllama ¶
type ProtocolConfigOpenAI ¶
type ProtocolConfigOpenAI struct {
ByAzure bool `json:"by_azure" yaml:"by_azure" mapstructure:"by_azure"`
ApiVersion string `json:"api_version" yaml:"api_version" mapstructure:"api_version"`
ResponseFormatType string `json:"response_format_type" yaml:"response_format_type" mapstructure:"response_format_type"`
ResponseFormatJsonSchema string `json:"response_format_json_schema" yaml:"response_format_json_schema" mapstructure:"response_format_json_schema"`
}
type ProtocolConfigQianfan ¶
type ProtocolConfigQianfan struct {
LLMRetryCount *int `json:"llm_retry_count" yaml:"llm_retry_count" mapstructure:"llm_retry_count"` // 重试次数
LLMRetryTimeout *float32 `json:"llm_retry_timeout" yaml:"llm_retry_timeout" mapstructure:"llm_retry_timeout"` // 重试超时时间
LLMRetryBackoffFactor *float32 `json:"llm_retry_backoff_factor" yaml:"llm_retry_backoff_factor" mapstructure:"llm_retry_backoff_factor"` // 重试退避因子
ParallelToolCalls *bool `json:"parallel_tool_calls" yaml:"parallel_tool_calls" mapstructure:"parallel_tool_calls"`
ResponseFormatType *string `json:"response_format_type" yaml:"response_format_type" mapstructure:"response_format_type"`
ResponseFormatJsonSchema *string `json:"response_format_json_schema" yaml:"response_format_json_schema" mapstructure:"response_format_json_schema"`
}
type ProtocolConfigQwen ¶
type ProtocolConfigQwen struct {
ResponseFormatType *string `json:"response_format_type" yaml:"response_format_type" mapstructure:"response_format_type"`
ResponseFormatJsonSchema *string `json:"response_format_json_schema" yaml:"response_format_json_schema" mapstructure:"response_format_json_schema"`
}
type ResponseFormat ¶
type ResponseFormat struct {
Type ResponseFormatType `json:"type,omitempty"`
}
type ResponseFormatType ¶
type ResponseFormatType string
const ( ResponseFormatTypeText ResponseFormatType = "text" ResponseFormatTypeJSON ResponseFormatType = "json_object" )
type ResponseMeta ¶
type ResponseMeta struct {
// FinishReason is the reason why the chat response is finished.
// It's usually "stop", "length", "tool_calls", "content_filter", "null". This is defined by chat model implementation.
FinishReason string `json:"finish_reason,omitempty"`
// Usage is the token usage of the chat response, whether usage exists depends on whether the chat model implementation returns.
Usage *TokenUsage `json:"usage,omitempty"`
}
ResponseMeta collects meta information about a chat response.
func ToDORespMeta ¶
func ToDORespMeta(rm *schema.ResponseMeta) *ResponseMeta
type Role ¶
type Role string
const ( // Assistant is the role of an assistant, means the message is returned by ChatModel. RoleAssistant Role = "assistant" // User is the role of a user, means the message is a user message. RoleUser Role = "user" // System is the role of a system, means the message is a system message. RoleSystem Role = "system" // Tool is the role of a tool, means the message is a tool call output. RoleTool Role = "tool" )
type RuntimeConfig ¶
type RuntimeConfig struct {
NeedCvtURLToBase64 bool `json:"need_cvt_url_to_base_64" yaml:"need_cvt_url_to_base_64" mapstructure:"need_cvt_url_to_base_64"`
QianfanAk string `json:"qianfan_ak" yaml:"qianfan_ak" mapstructure:"qianfan_ak"`
QianfanSk string `json:"qianfan_sk" yaml:"qianfan_sk" mapstructure:"qianfan_sk"`
}
type ScenarioConfig ¶
type StreamReader ¶
type StreamReader struct {
// contains filtered or unexported fields
}
func (*StreamReader) Recv ¶
func (sr *StreamReader) Recv() (message *Message, err error)
type StreamRespParseResult ¶
type TokenUsage ¶
type TokenUsage struct {
// PromptTokens is the number of tokens in the prompt.
PromptTokens int `json:"prompt_tokens"`
// CompletionTokens is the number of tokens in the completion.
CompletionTokens int `json:"completion_tokens"`
// TotalTokens is the total number of tokens in the request.
TotalTokens int `json:"total_tokens"`
}
TokenUsage Represents the token usage of chat model request.
func ToDOTokenUsage ¶
func ToDOTokenUsage(tu *schema.TokenUsage) *TokenUsage
type ToolCall ¶
type ToolCall struct {
// Index is used when there are multiple tool calls in a message.
// In stream mode, it's used to identify the chunk of the tool call for merging.
Index *int64 `json:"index,omitempty"`
// ID is the id of the tool call, it can be used to identify the specific tool call.
ID string `json:"id"`
// Type is the type of the tool call, default is "function".
Type string `json:"type"`
// Function is the function call to be made.
Function *FunctionCall `json:"function"`
// Extra is used to store extra information for the tool call.
Extra map[string]any `json:"extra,omitempty"`
}
func ToDOToolCall ¶
func ToDOToolCalls ¶
type ToolChoice ¶
type ToolChoice string
const ( ToolChoiceAuto ToolChoice = "auto" ToolChoiceRequired ToolChoice = "required" ToolChoiceNone ToolChoice = "none" )
type ToolDefType ¶
type ToolDefType string
const (
ToolDefTypeOpenAPIV3 ToolDefType = "open_api_v3"
)
type ToolInfo ¶
type ToolInfo struct {
// The unique name of the tool that clearly communicates its purpose.
Name string
// Used to tell the model how/when/why to use the tool.
// You can provide few-shot examples as a part of the description.
Desc string
ToolDefType ToolDefType
Def string
}
type Visibility ¶
type Visibility struct {
Mode VisibleMode `json:"mode"`
SpaceIDs []int64 `json:"space_ids"` // model为specified时有效
}
type VisibleMode ¶
type VisibleMode string
const ( VisibleModeUndefined VisibleMode = "undefined" VisibleModelAll VisibleMode = "all" VisibleModelSpecified VisibleMode = "specified" VisibleModelDefault VisibleMode = "default" )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.