Documentation
¶
Index ¶
- type AccountFilter
- type AliyunChatCompletionReq
- type AliyunChatCompletionRes
- type BaiduChatCompletionReq
- type BaiduChatCompletionRes
- type Button
- type Chat
- type ChatCompletionChoice
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Choice
- type Choices
- type Filter
- type Functions
- type Header
- type ImageRequest
- type ImageResponse
- type Input
- type Message
- type MidjourneyProxy
- type MidjourneyProxyFetchResponse
- type MidjourneyProxyRequest
- type MidjourneyProxyResponse
- type Output
- type Parameter
- type Parameters
- type Payload
- type Properties
- type SearchInfo
- type SearchResult
- type Text
- type Usage
- type XfyunChatCompletionReq
- type XfyunChatCompletionRes
- type ZhipuAIChatCompletionReq
- type ZhipuAIChatCompletionRes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountFilter ¶
type AccountFilter struct {
ChannelId string `json:"channelId,omitempty"`
InstanceId string `json:"instanceId,omitempty"`
Modes []string `json:"modes,omitempty"`
Remark string `json:"remark,omitempty"`
Remix bool `json:"remix,omitempty"`
RemixAutoConsidered bool `json:"remixAutoConsidered,omitempty"`
}
type AliyunChatCompletionReq ¶ added in v0.1.5
type AliyunChatCompletionReq struct {
// 指定用于对话的通义千问模型名
// 目前可选择qwen-turbo、qwen-plus、qwen-max、qwen-max-0403、qwen-max-0107、qwen-max-1201和qwen-max-longcontext。
Model string `json:"model"`
Input Input `json:"input"`
Parameters Parameters `json:"parameters"`
}
type AliyunChatCompletionRes ¶ added in v0.1.5
type AliyunChatCompletionRes struct {
// 入参result_format=text时候的返回值
Output Output `json:"output"`
Usage struct {
// 本次请求输入内容的 token 数目。
// 在打开了搜索的情况下,输入的 token 数目因为还需要添加搜索相关内容支持,所以会超出客户在请求中的输入。
InputTokens int `json:"input_tokens"`
// 本次请求算法输出内容的 token 数目。
OutputTokens int `json:"output_tokens"`
} `json:"usage"`
// 本次请求的系统唯一码。
RequestId string `json:"request_id"`
Code string `json:"code"`
Message string `json:"message"`
}
type BaiduChatCompletionReq ¶ added in v0.1.5
type BaiduChatCompletionReq struct {
// 聊天上下文信息。说明:
//(1)messages成员不能为空,1个成员表示单轮对话,多个成员表示多轮对话,例如:
// 1个成员示例,"messages": [ {"role": "user","content": "你好"}]
// 3个成员示例,"messages": [ {"role": "user","content": "你好"},{"role":"assistant","content":"需要什么帮助"},{"role":"user","content":"自我介绍下"}]
//(2)最后一个message为当前请求的信息,前面的message为历史对话信息
//(3)成员数目必须为奇数,成员中message的role值说明如下:奇数位message的role值必须为user,偶数位message的role值为assistant。例如:
// 示例中message中的role值分别为user、assistant、user、assistant、user;奇数位(红框)message中的role值为user,即第1、3、5个message中的role值为user;偶数位(蓝框)值为assistant,即第2、4个message中的role值为assistant
Messages []openai.ChatCompletionMessage `json:"messages"`
//(1)较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定
//(2)默认0.8,范围 (0, 1.0],不能为0
Temperature float32 `json:"temperature,omitempty"`
//(1)影响输出文本的多样性,取值越大,生成文本的多样性越强
//(2)默认0.8,取值范围 [0, 1.0]
TopP float32 `json:"top_p,omitempty"`
// 通过对已生成的token增加惩罚,减少重复生成的现象。说明:
//(1)值越大表示惩罚越大
//(2)默认1.0,取值范围:[1.0, 2.0]
PenaltyScore float32 `json:"penalty_score,omitempty"`
// 是否以流式接口的形式返回数据,默认false
Stream bool `json:"stream,omitempty"`
// 模型人设,主要用于人设设定,例如,你是xxx公司制作的AI助手,说明:
//(1)长度限制,最后一个message的content长度(即此轮对话的问题)和system字段总内容不能超过20000个字符,且不能超过5120 tokens
System string `json:"system,omitempty"`
// 生成停止标识,当模型生成结果以stop中某个元素结尾时,停止文本生成。说明:
//(1)每个元素长度不超过20字符
//(2)最多4个元素
Stop []string `json:"stop,omitempty"`
// 是否强制关闭实时搜索功能,默认false,表示不关闭
DisableSearch bool `json:"disable_search,omitempty"`
// 是否开启上角标返回,说明:
//(1)开启后,有概率触发搜索溯源信息search_info,search_info内容见响应参数介绍
//(2)默认false,不开启
EnableCitation bool `json:"enable_citation,omitempty"`
// 指定模型最大输出token数,说明:
//(1)如果设置此参数,范围[2, 2048]
//(2)如果不设置此参数,最大输出token数为1024
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
// 指定响应内容的格式,说明:
//(1)可选值:
// json_object:以json格式返回,可能出现不满足效果情况
// text:以文本格式返回
//(2)如果不填写参数response_format值,默认为text
ResponseFormat string `json:"response_format,omitempty"`
// 表示最终用户的唯一标识符
UserId string `json:"user_id,omitempty"`
}
type BaiduChatCompletionRes ¶ added in v0.1.5
type BaiduChatCompletionRes struct {
// 本轮对话的id
Id string `json:"id"`
// 回包类型
// chat.completion:多轮对话返回
Object string `json:"object"`
// 时间戳
Created int64 `json:"created"`
// 表示当前子句的序号。只有在流式接口模式下会返回该字段
SentenceId int `json:"sentence_id"`
// 表示当前子句是否是最后一句。只有在流式接口模式下会返回该字段
IsEnd bool `json:"is_end"`
// 当前生成的结果是否被截断
IsTruncated bool `json:"is_truncated"`
// 输出内容标识,说明:
// normal:输出内容完全由大模型生成,未触发截断、替换
// stop:输出结果命中入参stop中指定的字段后被截断
// length:达到了最大的token数,根据EB返回结果is_truncated来截断
// content_filter:输出内容被截断、兜底、替换为**等
FinishReason string `json:"finish_reason"`
// 搜索数据,当请求参数enable_citation为true并且触发搜索时,会返回该字段
SearchInfo *SearchInfo
// 对话返回结果
Result string `json:"result"`
// 表示用户输入是否存在安全风险,是否关闭当前会话,清理历史会话信息
// true:是,表示用户输入存在安全风险,建议关闭当前会话,清理历史会话信息
// false:否,表示用户输入无安全风险
NeedClearHistory bool `json:"need_clear_history"`
// 0:正常返回
// 其他:非正常
Flag int `json:"flag"`
// 当need_clear_history为true时,此字段会告知第几轮对话有敏感信息,如果是当前问题,ban_round=-1
BanRound int `json:"ban_round"`
// token统计信息
Usage *openai.Usage `json:"usage,omitempty"`
ErrorCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
}
type Chat ¶ added in v0.1.2
type Chat struct {
// 指定访问的领域:
// general指向V1.5版本;
// generalv2指向V2版本;
// generalv3指向V3版本;
// generalv3.5指向V3.5版本;
// 注意:不同的取值对应的url也不一样!
Domain string `json:"domain"`
// 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高
// 取值范围 (0,1] ,默认值0.5
Temperature float32 `json:"temperature,omitempty"`
// 模型回答的tokens的最大长度
// V1.5取值为[1,4096]
// V2.0、V3.0和V3.5取值为[1,8192],默认为2048。
MaxTokens int `json:"max_tokens"`
// 从k个候选中随机选择⼀个(⾮等概率)
// 取值为[1,6],默认为4
TopK int `json:"top_k,omitempty"`
// 用于关联用户会话
// 需要保障用户下的唯一性
ChatId string `json:"chat_id,omitempty"`
}
type ChatCompletionChoice ¶ added in v0.1.2
type ChatCompletionChoice struct {
Index int `json:"index"`
Message *openai.ChatCompletionMessage `json:"message,omitempty"`
Delta *openai.ChatCompletionStreamChoiceDelta `json:"delta,omitempty"`
LogProbs *openai.LogProbs `json:"logprobs,omitempty"`
FinishReason openai.FinishReason `json:"finish_reason"`
ContentFilterResults *openai.ContentFilterResults `json:"content_filter_results,omitempty"`
}
type ChatCompletionRequest ¶ added in v0.1.2
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []openai.ChatCompletionMessage `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"top_p,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"`
ResponseFormat *openai.ChatCompletionResponseFormat `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
// LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string.
// incorrect: `"logit_bias":{"You": 6}`, correct: `"logit_bias":{"1639": 6}`
// refs: https://platform.openai.com/docs/api-reference/chat/create#chat/create-logit_bias
LogitBias map[string]int `json:"logit_bias,omitempty"`
// LogProbs indicates whether to return log probabilities of the output tokens or not.
// If true, returns the log probabilities of each output token returned in the content of message.
// This option is currently not available on the gpt-4-vision-preview model.
LogProbs bool `json:"logprobs,omitempty"`
// TopLogProbs is an integer between 0 and 5 specifying the number of most likely tokens to return at each
// token position, each with an associated log probability.
// logprobs must be set to true if this parameter is used.
TopLogProbs int `json:"top_logprobs,omitempty"`
User string `json:"user,omitempty"`
Functions []openai.FunctionDefinition `json:"functions,omitempty"`
FunctionCall any `json:"function_call,omitempty"`
Tools []openai.Tool `json:"tools,omitempty"`
// This can be either a string or an ToolChoice object.
ToolChoice any `json:"tool_choice,omitempty"`
}
ChatCompletionRequest represents a request structure for chat completion API.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChoice `json:"choices"`
Usage *openai.Usage `json:"usage"`
SystemFingerprint string `json:"system_fingerprint,omitempty"`
PromptAnnotations []openai.PromptAnnotation `json:"prompt_annotations,omitempty"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
}
ChatCompletionResponse represents a response structure for chat completion API.
type Choice ¶ added in v0.1.5
type Choice struct {
// 结果下标
Index int `json:"index"`
// 模型推理终止的原因。
// stop代表推理自然结束或触发停止词。
// tool_calls 代表模型命中函数。
// length代表到达 tokens 长度上限。
// sensitive 代表模型推理内容被安全审核接口拦截。请注意,针对此类内容,请用户自行判断并决定是否撤回已公开的内容。
// network_error 代表模型推理异常。
FinishReason openai.FinishReason `json:"finish_reason"`
// 模型返回的文本信息
Message *openai.ChatCompletionMessage `json:"message,omitempty"`
// 模型返回的文本信息-流式
Delta *openai.ChatCompletionStreamChoiceDelta `json:"delta,omitempty"`
}
type Functions ¶ added in v0.1.3
type Functions struct {
// req
Text []openai.FunctionDefinition `json:"text"`
}
type Header ¶ added in v0.1.2
type Header struct {
// req
AppId string `json:"app_id"` // 应用appid,从开放平台控制台创建的应用中获取
Uid string `json:"uid"` // 每个用户的id,用于区分不同用户,最大长度32
// res
Code int `json:"code,omitempty"` // 错误码,0表示正常,非0表示出错;详细释义可在接口说明文档最后的错误码说明了解
Message string `json:"message,omitempty"` // 会话是否成功的描述信息
Sid string `json:"sid,omitempty"` // 会话的唯一id,用于讯飞技术人员查询服务端会话日志使用,出现调用错误时建议留存该字段
Status int `json:"status,omitempty"` // 会话状态,取值为[0,1,2];0代表首次结果;1代表中间结果;2代表最后一个结果
}
type ImageRequest ¶ added in v0.1.2
type ImageRequest struct {
Prompt string `json:"prompt,omitempty"`
Model string `json:"model,omitempty"`
N int `json:"n,omitempty"`
Quality string `json:"quality,omitempty"`
Size string `json:"size,omitempty"`
Style string `json:"style,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
User string `json:"user,omitempty"`
}
ImageRequest represents the request structure for the image API.
type ImageResponse ¶
type ImageResponse struct {
Created int64 `json:"created,omitempty"`
Data []openai.ImageResponseDataInner `json:"data,omitempty"`
TotalTime int64 `json:"-"`
}
type Input ¶ added in v0.1.4
type Input struct {
// 用户与模型的对话历史,list中的每个元素形式为{"role":角色, "content": 内容}。
// 角色当前可选值:system、user、assistant和tool。未来可以扩展到更多role。
Messages []openai.ChatCompletionMessage `json:"messages"`
}
type Message ¶ added in v0.1.2
type Message struct {
// req
Text []openai.ChatCompletionMessage `json:"text"`
}
type MidjourneyProxy ¶
type MidjourneyProxy struct {
ApiSecret string `json:"api_secret"`
ApiSecretHeader string `json:"api_secret_header"`
ImagineUrl string `json:"imagine_url"`
ChangeUrl string `json:"change_url"`
DescribeUrl string `json:"describe_url"`
BlendUrl string `json:"blend_url"`
SwapFaceUrl string `json:"swap_face_url"`
ActionUrl string `json:"action_url"`
ModalUrl string `json:"modal_url"`
ShortenUrl string `json:"shorten_url"`
UploadDiscordImagesUrl string `json:"upload_discord_images_url"`
FetchUrl string `json:"fetch_url"`
}
type MidjourneyProxyFetchResponse ¶
type MidjourneyProxyFetchResponse struct {
Id string `json:"id,omitempty"`
Action string `json:"action,omitempty"`
Buttons []*Button `json:"buttons,omitempty"`
Description string `json:"description,omitempty"`
FailReason string `json:"failReason,omitempty"`
ImageUrl string `json:"imageUrl,omitempty"`
Progress string `json:"progress,omitempty"`
Prompt string `json:"prompt,omitempty"`
PromptEn string `json:"promptEn,omitempty"`
Properties *Properties `json:"properties,omitempty"`
SubmitTime int `json:"submitTime,omitempty"`
StartTime int `json:"startTime,omitempty"`
FinishTime int `json:"finishTime,omitempty"`
State string `json:"state,omitempty"`
Status string `json:"status,omitempty"`
TotalTime int64 `json:"-"`
}
type MidjourneyProxyRequest ¶
type MidjourneyProxyRequest struct {
Prompt string `json:"prompt,omitempty"`
Base64 string `json:"base64,omitempty"`
Base64Array []string `json:"base64Array,omitempty"`
Action string `json:"action,omitempty"`
Index int `json:"index,omitempty"`
TaskId string `json:"taskId,omitempty"`
SourceBase64 string `json:"sourceBase64,omitempty"`
TargetBase64 string `json:"targetBase64,omitempty"`
NotifyHook string `json:"notifyHook,omitempty"`
State string `json:"state,omitempty"`
BotType string `json:"botType,omitempty"`
Dimensions string `json:"dimensions,omitempty"`
AccountFilter *AccountFilter `json:"accountFilter,omitempty"`
MaskBase64 string `json:"maskBase64,omitempty"`
Filter *Filter `json:"filter,omitempty"`
}
type MidjourneyProxyResponse ¶
type MidjourneyProxyResponse struct {
Code int `json:"code,omitempty"`
Description string `json:"description,omitempty"`
Result string `json:"result,omitempty"`
Properties *Properties `json:"properties,omitempty"`
TotalTime int64 `json:"-"`
}
type Output ¶ added in v0.1.4
type Output struct {
// 包含本次请求的算法输出内容。
Text string `json:"text"`
// 有三种情况:正在生成时为null,生成结束时如果由于停止token导致则为stop,生成结束时如果因为生成长度过长导致则为length。
FinishReason openai.FinishReason `json:"finish_reason"`
// 入参result_format=message时候的返回值
Choices []ChatCompletionChoice `json:"choices"`
}
type Parameters ¶ added in v0.1.4
type Parameters struct {
// "text"表示旧版本的text
// "message"表示兼容openai的message
ResultFormat string `json:"resultFormat,omitempty"`
// 生成时使用的随机数种子,用户控制模型生成内容的随机性。
// seed支持无符号64位整数,默认值为1234。
// 在使用seed时,模型将尽可能生成相同或相似的结果,但目前不保证每次生成的结果完全相同。
Seed *int `json:"seed,omitempty"`
// 用于限制模型生成token的数量,max_tokens设置的是生成上限,并不表示一定会生成这么多的token数量。
// 其中qwen-turbo最大值和默认值为1500,qwen-max、qwen-max-1201 、qwen-max-longcontext 和 qwen-plus最大值和默认值均为2000。
MaxTokens int `json:"max_tokens,omitempty"`
// 生成时,核采样方法的概率阈值。
// 例如,取值为0.8时,仅保留累计概率之和大于等于0.8的概率分布中的token,作为随机采样的候选集。
// 取值范围为(0,1.0),取值越大,生成的随机性越高;取值越低,生成的随机性越低。
// 默认值为0.8。注意,取值不要大于等于1
TopP float32 `json:"top_p,omitempty"`
// 生成时,采样候选集的大小。
// 例如,取值为50时,仅将单次生成中得分最高的50个token组成随机采样的候选集。
// 取值越大,生成的随机性越高;取值越小,生成的确定性越高。
// 注意:如果top_k参数为空或者top_k的值大于100,表示不启用top_k策略,此时仅有top_p策略生效,默认是空。
TopK int `json:"top_k,omitempty"`
// 用于控制模型生成时的重复度。
// 提高repetition_penalty时可以降低模型生成的重复度。
// 1.0表示不做惩罚。默认为1.1。
RepetitionPenalty float32 `json:"repetition_penalty,omitempty"`
// 用于控制随机性和多样性的程度。
// 具体来说,temperature值控制了生成文本时对每个候选词的概率分布进行平滑的程度。
// 较高的temperature值会降低概率分布的峰值,使得更多的低概率词被选择,生成结果更加多样化;
// 而较低的temperature值则会增强概率分布的峰值,使得高概率词更容易被选择,生成结果更加确定。
// 取值范围:[0, 2),系统默认值0.85。不建议取值为0,无意义。
Temperature float32 `json:"temperature,omitempty"`
// stop参数用于实现内容生成过程的精确控制,在生成内容即将包含指定的字符串或token_ids时自动停止,生成内容不包含指定的内容。
// 例如,如果指定stop为"你好",表示将要生成"你好"时停止;如果指定stop为[37763, 367],表示将要生成"Observation"时停止。
// stop参数支持以list方式传入字符串数组或者token_ids数组,支持使用多个stop的场景。
Stop []string `json:"stop,omitempty"` // String/List[String]用于指定字符串;List[Integer]/List[List[Integer]]用于指定token_ids;注意: list模式下不支持字符串和token_ids混用,元素类型要相同。
// 模型内置了互联网搜索服务,该参数控制模型在生成文本时是否参考使用互联网搜索结果。取值如下:
// true:启用互联网搜索,模型会将搜索结果作为文本生成过程中的参考信息,但模型会基于其内部逻辑“自行判断”是否使用互联网搜索结果。
// false(默认):关闭互联网搜索。
EnableSearch bool `json:"enable_search,omitempty"`
// 用于控制流式输出模式,默认false,即后面内容会包含已经输出的内容;
// 设置为true,将开启增量输出模式,后面输出不会包含已经输出的内容,您需要自行拼接整体输出,参考流式输出示例代码。
// 该参数只能与stream输出模式配合使用。
// 注意: incremental_output暂时无法和tools参数同时使用。
IncrementalOutput bool `json:"incremental_output,omitempty"`
// 模型可选调用的工具列表。目前仅支持function,并且即使输入多个function,模型仅会选择其中一个生成结果。
// 模型根据tools参数内容可以生产函数调用的参数,tools中每一个tool的结构如下:
// type,类型为string,表示tools的类型,当前仅支持function。
// function,类型为dict,包括name,description和parameters:
// name,类型为string,表示function的名称,必须是字母、数字,或包含下划线和短划线,最大长度为64。
// description,类型为string,表示function的描述,供模型选择何时以及如何调用function。
// parameters,类型为dict,表示function的参数描述,需要是一个合法的json schema。json schema的描述可以见链接。参考代码中给出了一个参数描述的示例。如果parameters参数缺省了,表示function没有入参。
// 使用tools功能时需要指定result_format为message。
// 在多轮对话中,无论是发起function_call的轮次,还是向模型提交function的执行结果,均请设置tools参数。
// 当前支持qwen-turbo、qwen-plus、qwen-max和qwen-max-longcontext。
// 注意: tools暂时无法和incremental_output参数同时使用。
Tools []openai.Tool `json:"tools,omitempty"`
}
type Properties ¶
type Properties struct {
NotifyHook string `json:"notifyHook,omitempty"`
FinalPrompt string `json:"finalPrompt,omitempty"`
MessageId string `json:"messageId,omitempty"`
MessageHash string `json:"messageHash,omitempty"`
ProgressMessageId string `json:"progressMessageId,omitempty"`
Flags int `json:"flags,omitempty"`
Nonce string `json:"nonce,omitempty"`
DiscordInstanceId string `json:"discordInstanceId,omitempty"`
PromptEn string `json:"promptEn,omitempty"`
BannedWord string `json:"bannedWord,omitempty"`
}
type SearchInfo ¶ added in v0.1.4
type SearchInfo struct {
SearchResults []SearchResult `json:"search_results,omitempty"` // 搜索结果列表
}
type SearchResult ¶ added in v0.1.4
type Text ¶ added in v0.1.2
type Text struct {
// 角色标识,固定为assistant,标识角色为AI
Role string `json:"role,omitempty"`
// AI的回答内容
Content string `json:"content,omitempty"`
// 结果序号,取值为[0,10]; 当前为保留字段,开发者可忽略
Index int `json:"index,omitempty"`
// 内容类型
ContentType string `json:"content_type,omitempty"`
// function call 返回结果
FunctionCall *openai.FunctionCall `json:"function_call,omitempty"`
// 保留字段,可忽略
QuestionTokens int `json:"question_tokens,omitempty"`
// 包含历史问题的总tokens大小
PromptTokens int `json:"prompt_tokens,omitempty"`
// 回答的tokens大小
CompletionTokens int `json:"completion_tokens,omitempty"`
// prompt_tokens和completion_tokens的和,也是本次交互计费的tokens大小
TotalTokens int `json:"total_tokens,omitempty"`
}
type XfyunChatCompletionReq ¶ added in v0.1.5
type XfyunChatCompletionRes ¶ added in v0.1.5
type ZhipuAIChatCompletionReq ¶ added in v0.1.5
type ZhipuAIChatCompletionReq struct {
// 所要调用的模型编码
Model string `json:"model"`
// 调用语言模型时,将当前对话信息列表作为提示输入给模型
// 按照 {"role": "user", "content": "你好"} 的json 数组形式进行传参
// 可能的消息类型包括 System message、User message、Assistant message 和 Tool message。
Messages []openai.ChatCompletionMessage `json:"messages"`
// 由用户端传参,需保证唯一性;用于区分每次请求的唯一标识,用户端不传时平台会默认生成。
RequestId string `json:"request_id,omitempty"`
// do_sample 为 true 时启用采样策略,do_sample 为 false 时采样策略 temperature、top_p 将不生效。默认值为 true。
DoSample bool `json:"do_sample,omitempty"`
// 使用同步调用时,此参数应当设置为 fasle 或者省略。表示模型生成完所有内容后一次性返回所有内容。默认值为 false。
// 如果设置为 true,模型将通过标准 Event Stream ,逐块返回模型生成内容。Event Stream 结束时会返回一条data: [DONE]消息。
// 注意:在模型流式输出生成内容的过程中,我们会分批对模型生成内容进行检测,当检测到违法及不良信息时,API会返回错误码(1301)。
// 开发者识别到错误码(1301),应及时采取(清屏、重启对话)等措施删除生成内容,并确保不将含有违法及不良信息的内容传递给模型继续生成,避免其造成负面影响。
Stream bool `json:"stream,omitempty"`
// 采样温度,控制输出的随机性,必须为正数
// 取值范围是:(0.0, 1.0),不能等于 0,默认值为 0.95,值越大,会使输出更随机,更具创造性;值越小,输出会更加稳定或确定
// 建议您根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数
Temperature float32 `json:"temperature,omitempty"`
// 用温度取样的另一种方法,称为核取样
// 取值范围是:(0.0, 1.0) 开区间,不能等于 0 或 1,默认值为 0.7
// 模型考虑具有 top_p 概率质量 tokens 的结果
// 例如:0.1 意味着模型解码器只考虑从前 10% 的概率的候选集中取 tokens
// 建议您根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数
TopP float32 `json:"top_p,omitempty"`
// 模型输出最大 tokens,最大输出为8192,默认值为1024
MaxTokens int `json:"max_tokens,omitempty"`
// 模型在遇到stop所制定的字符时将停止生成,目前仅支持单个停止词,格式为["stop_word1"]
Stop []string `json:"stop,omitempty"`
// 可供模型调用的工具列表,tools 字段会计算 tokens ,同样受到 tokens 长度的限制
Tools []openai.Tool `json:"tools,omitempty"`
// 用于控制模型是如何选择要调用的函数,仅当工具类型为function时补充。默认为auto,当前仅支持auto
ToolChoice any `json:"tool_choice,omitempty"`
// 终端用户的唯一ID,协助平台对终端用户的违规行为、生成违法及不良信息或其他滥用行为进行干预。ID长度要求:最少6个字符,最多128个字符。
UserId string `json:"user_id,omitempty"`
}
type ZhipuAIChatCompletionRes ¶ added in v0.1.5
Click to show internal directories.
Click to hide internal directories.