Documentation
¶
Index ¶
- type AccountFilter
- type AliyunChatCompletionReq
- type AliyunChatCompletionRes
- type AnthropicChatCompletionReq
- type AnthropicChatCompletionRes
- type AnthropicContent
- type AnthropicError
- type AnthropicErrorResponse
- type AnthropicMessage
- type AnthropicTool
- type AnthropicUsage
- type Audio
- type AudioRequest
- type AudioResponse
- type BaiduChatCompletionReq
- type BaiduChatCompletionRes
- type BatchCancelRequest
- type BatchCreateRequest
- type BatchError
- type BatchListRequest
- type BatchListResponse
- type BatchRequestInput
- type BatchRequestOutput
- type BatchResponse
- type BatchRetrieveRequest
- type Button
- type Candidate
- type Chat
- type ChatCompletionChoice
- type ChatCompletionMessage
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatCompletionResponseFormat
- type ChatCompletionStreamChoiceDelta
- type Choices
- type CompletionTokensDetails
- type Content
- type ContentBlock
- type ContentFilterResults
- type EmbeddingRequest
- type EmbeddingResponse
- type ExpiresAfter
- type FileContentRequest
- type FileContentResponse
- type FileData
- type FileDeleteRequest
- type FileListRequest
- type FileListResponse
- type FileResponse
- type FileRetrieveRequest
- type FileUploadRequest
- type Filter
- type FunctionCall
- type FunctionDefinition
- type Functions
- type GenerationConfig
- type GoogleChatCompletionReq
- type GoogleChatCompletionRes
- type GoogleFile
- type GoogleFileListResponse
- type GoogleFileResponse
- type GoogleImageGenerationReq
- type Hate
- type Header
- type ImageConfig
- type ImageEditRequest
- type ImageGenerationRequest
- type ImageResponse
- type ImageResponseData
- type InlineData
- type Input
- type InputTokensDetails
- type JailBreak
- type LogProb
- type LogProbs
- type Message
- type Metadata
- type MidjourneyProxyFetchResponse
- type MidjourneyProxyRequest
- type MidjourneyProxyResponse
- type MidjourneyResponse
- type ModerationRequest
- type ModerationResponse
- type OpenAIResponsesContent
- type OpenAIResponsesError
- type OpenAIResponsesFormat
- type OpenAIResponsesInput
- type OpenAIResponsesItem
- type OpenAIResponsesOutput
- type OpenAIResponsesPart
- type OpenAIResponsesReasoning
- type OpenAIResponsesReq
- type OpenAIResponsesRes
- type OpenAIResponsesResponse
- type OpenAIResponsesStreamRes
- type OpenAIResponsesSummary
- type OpenAIResponsesText
- type Output
- type OutputExpiresAfter
- type OutputTokensDetails
- type Parameter
- type Parameters
- type Part
- type Payload
- type Profanity
- type PromptAnnotation
- type PromptTokensDetails
- type Properties
- type RealtimeRequest
- type RealtimeResponse
- type RequestCounts
- type SafetyRating
- type SearchInfo
- type SearchResult
- type Segment
- type SelfHarm
- type Sexual
- type Source
- type SpeechRequest
- type SpeechResponse
- type StreamOptions
- type Text
- type ToolCall
- type TopLogProbs
- type Usage
- type UsageMetadata
- type VideoContentRequest
- type VideoContentResponse
- type VideoCreateRequest
- type VideoDeleteRequest
- type VideoError
- type VideoJobResponse
- type VideoListRequest
- type VideoListResponse
- type VideoRemixRequest
- type VideoRetrieveRequest
- type Violence
- type VolcVideoContent
- type VolcVideoContentResult
- type VolcVideoCreateReq
- type VolcVideoDeleteReq
- type VolcVideoDraftTask
- type VolcVideoError
- type VolcVideoListReq
- type VolcVideoListRes
- type VolcVideoMediaUrl
- type VolcVideoRetrieveReq
- type VolcVideoTaskRes
- type VolcVideoTool
- type VolcVideoToolUsage
- type VolcVideoUsage
- type Word
- type XfyunChatCompletionReq
- type XfyunChatCompletionRes
- type XfyunUsage
- type ZhipuAIChatCompletionReq
- type ZhipuAIChatCompletionRes
- type ZhipuAIError
- type ZhipuAIErrorResponse
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 ¶
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 ¶
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 AnthropicChatCompletionReq ¶
type AnthropicChatCompletionReq struct {
Model string `json:"model,omitempty"`
Messages []ChatCompletionMessage `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
Stream bool `json:"stream,omitempty"`
System any `json:"system,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
Tools any `json:"tools,omitempty"`
TopK int `json:"top_k,omitempty"`
TopP float32 `json:"top_p,omitempty"`
AnthropicVersion string `json:"anthropic_version,omitempty"`
}
type AnthropicChatCompletionRes ¶
type AnthropicChatCompletionRes struct {
Id string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []AnthropicContent `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
StopSequence string `json:"stop_sequence"`
Message AnthropicMessage `json:"message"`
Index int `json:"index"`
Delta AnthropicContent `json:"delta"`
Usage *AnthropicUsage `json:"usage,omitempty"`
Error *AnthropicError `json:"error,omitempty"`
SSEEvent string `json:"-"`
ResponseBytes []byte `json:"-"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
Err error `json:"-"`
}
type AnthropicContent ¶
type AnthropicError ¶
type AnthropicErrorResponse ¶
type AnthropicErrorResponse struct {
Error *AnthropicError `json:"error,omitempty"`
}
type AnthropicMessage ¶
type AnthropicTool ¶
type AnthropicUsage ¶
type AnthropicUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheCreationInputTokens int `json:"cache_creation_input_tokens"`
CacheReadInputTokens int `json:"cache_read_input_tokens"`
CacheCreation struct {
Ephemeral5MInputTokens int `json:"ephemeral_5m_input_tokens"`
Ephemeral1HInputTokens int `json:"ephemeral_1h_input_tokens"`
} `json:"cache_creation"`
ServiceTier string `json:"service_tier"`
}
type AudioRequest ¶
type AudioRequest struct {
Model string `json:"model"`
File *multipart.FileHeader `json:"file"`
Prompt string `json:"prompt"`
Temperature float32 `json:"temperature"`
Language string `json:"language"`
ResponseFormat string `json:"response_format"`
TimestampGranularities []string `json:"timestamp_granularities"`
}
type AudioResponse ¶
type AudioResponse struct {
Task string `json:"task,omitempty"`
Language string `json:"language,omitempty"`
Duration float64 `json:"duration,omitempty"`
Segments []Segment `json:"segments,omitempty"`
Words []Word `json:"words,omitempty"`
Text string `json:"text,omitempty"`
Usage struct {
Type string `json:"type"`
Seconds int `json:"seconds"`
} `json:"usage"`
TotalTime int64 `json:"-"`
}
type BaiduChatCompletionReq ¶
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 []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 ¶
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 *Usage `json:"usage,omitempty"`
ErrorCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
}
type BatchCancelRequest ¶
type BatchCancelRequest struct {
BatchId string `json:"batch_id"`
}
type BatchCreateRequest ¶
type BatchCreateRequest struct {
InputFileId string `json:"input_file_id"`
Endpoint string `json:"endpoint"`
CompletionWindow string `json:"completion_window"`
Metadata any `json:"metadata,omitempty"`
OutputExpiresAfter *OutputExpiresAfter `json:"output_expires_after,omitempty"`
Model string `json:"-"`
}
type BatchError ¶
type BatchListRequest ¶
type BatchListResponse ¶
type BatchRequestInput ¶
type BatchRequestOutput ¶
type BatchRequestOutput struct {
Id string `json:"id"`
CustomId string `json:"custom_id"`
Response struct {
StatusCode int `json:"status_code"`
RequestId string `json:"request_id"`
Body struct {
Id string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
Choices []struct {
Index int `json:"index"`
Message struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"message"`
FinishReason string `json:"finish_reason"`
} `json:"choices"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
} `json:"usage"`
SystemFingerprint interface{} `json:"system_fingerprint"`
} `json:"body"`
} `json:"response"`
Error interface{} `json:"error"`
}
type BatchResponse ¶
type BatchResponse struct {
Id string `json:"id"`
Object string `json:"object"`
Endpoint string `json:"endpoint"`
Model string `json:"model"`
InputFileId string `json:"input_file_id"`
CompletionWindow string `json:"completion_window"`
Status string `json:"status"`
OutputFileId string `json:"output_file_id"`
ErrorFileId string `json:"error_file_id"`
CreatedAt int64 `json:"created_at"`
InProgressAt int64 `json:"in_progress_at"`
ExpiresAt int64 `json:"expires_at"`
FinalizingAt int64 `json:"finalizing_at"`
CompletedAt int64 `json:"completed_at"`
FailedAt int64 `json:"failed_at"`
ExpiredAt int64 `json:"expired_at"`
CancellingAt int64 `json:"cancelling_at"`
CancelledAt int64 `json:"cancelled_at"`
RequestCounts RequestCounts `json:"request_counts"`
Metadata any `json:"metadata"`
Usage Usage `json:"usage"`
Errors *BatchError `json:"errors"`
ResponseBytes []byte `json:"-"`
TotalTime int64 `json:"-"`
}
type BatchRetrieveRequest ¶
type BatchRetrieveRequest struct {
BatchId string `json:"batch_id"`
}
type Candidate ¶
type Candidate struct {
Content Content `json:"content"`
FinishReason string `json:"finishReason"`
Index int `json:"index"`
SafetyRatings []SafetyRating `json:"safetyRatings"`
}
type Chat ¶
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,omitempty"`
// 从k个候选中随机选择⼀个(⾮等概率)
// 取值为[1,6],默认为4
TopK int `json:"top_k,omitempty"`
// 用于关联用户会话
// 需要保障用户下的唯一性
ChatId string `json:"chat_id,omitempty"`
// 图片的宽度
Width int `json:"width,omitempty"`
// 图片的宽度
Height int `json:"height,omitempty"`
}
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
Index int `json:"index"`
Message *ChatCompletionMessage `json:"message,omitempty"`
Delta *ChatCompletionStreamChoiceDelta `json:"delta,omitempty"`
LogProbs *LogProbs `json:"logprobs"`
FinishReason string `json:"finish_reason"`
}
type ChatCompletionMessage ¶
type ChatCompletionMessage struct {
Role string `json:"role"`
Content any `json:"content"`
ReasoningContent any `json:"reasoning_content,omitempty"`
Refusal *string `json:"refusal,omitempty"`
Name string `json:"name,omitempty"`
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls any `json:"tool_calls,omitempty"`
ToolCallId string `json:"tool_call_id,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Annotations []any `json:"annotations,omitempty"`
Prefix bool `json:"prefix,omitempty"`
}
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []ChatCompletionMessage `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
N int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"`
ResponseFormat *ChatCompletionResponseFormat `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
LogProbs bool `json:"logprobs,omitempty"`
TopLogProbs int `json:"top_logprobs,omitempty"`
User string `json:"user,omitempty"`
Functions []FunctionDefinition `json:"functions,omitempty"`
FunctionCall any `json:"function_call,omitempty"`
Tools any `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
ParallelToolCalls any `json:"parallel_tool_calls,omitempty"`
Store bool `json:"store,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Modalities []string `json:"modalities,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Audio *Audio `json:"audio,omitempty"`
WebSearchOptions any `json:"web_search_options,omitempty"`
EnableThinking *bool `json:"enable_thinking,omitempty"`
}
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 *Usage `json:"usage,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
SystemFingerprint string `json:"system_fingerprint,omitempty"`
Obfuscation string `json:"obfuscation,omitempty"`
PromptAnnotations []PromptAnnotation `json:"prompt_annotations,omitempty"`
SSEEvent string `json:"-"`
ResponseBytes []byte `json:"-"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
Error error `json:"-"`
}
type ChatCompletionStreamChoiceDelta ¶
type ChatCompletionStreamChoiceDelta struct {
Content string `json:"content"`
ReasoningContent any `json:"reasoning_content,omitempty"`
Role string `json:"role,omitempty"`
FunctionCall *FunctionCall `json:"function_call,omitempty"`
ToolCalls any `json:"tool_calls,omitempty"`
Refusal *string `json:"refusal,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Annotations any `json:"annotations,omitempty"`
}
type CompletionTokensDetails ¶
type CompletionTokensDetails struct {
AudioTokens int `json:"audio_tokens,omitempty"`
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
CachedTokens int `json:"cached_tokens,omitempty"`
CachedTokensInternal int `json:"cached_tokens_internal,omitempty"`
TextTokens int `json:"text_tokens,omitempty"`
ImageTokens int `json:"image_tokens,omitempty"`
AcceptedPredictionTokens int `json:"accepted_prediction_tokens,omitempty"`
RejectedPredictionTokens int `json:"rejected_prediction_tokens,omitempty"`
}
type ContentBlock ¶
type ContentFilterResults ¶
type ContentFilterResults struct {
Hate Hate `json:"hate,omitempty"`
SelfHarm SelfHarm `json:"self_harm,omitempty"`
Sexual Sexual `json:"sexual,omitempty"`
Violence Violence `json:"violence,omitempty"`
JailBreak JailBreak `json:"jailbreak,omitempty"`
Profanity Profanity `json:"profanity,omitempty"`
}
type EmbeddingRequest ¶
type EmbeddingRequest struct {
Input any `json:"input"`
Model string `json:"model"`
User string `json:"user"`
EncodingFormat string `json:"encoding_format,omitempty"`
// Dimensions The number of dimensions the resulting output embeddings should have.
// Only supported in text-embedding-3 and later models.
Dimensions int `json:"dimensions,omitempty"`
}
type EmbeddingResponse ¶
type ExpiresAfter ¶
type FileContentRequest ¶
type FileContentRequest struct {
FileId string `json:"file_id"`
}
type FileContentResponse ¶
type FileDeleteRequest ¶
type FileDeleteRequest struct {
FileId string `json:"file_id"`
}
type FileListRequest ¶
type FileListResponse ¶
type FileResponse ¶
type FileResponse struct {
Id string `json:"id"`
Object string `json:"object"`
Purpose string `json:"purpose"`
Filename string `json:"filename"`
Bytes int `json:"bytes"`
CreatedAt int64 `json:"created_at"`
ExpiresAt int64 `json:"expires_at"`
Status string `json:"status"`
StatusDetails *string `json:"status_details"`
Deleted bool `json:"deleted,omitempty"`
FileUrl string `json:"file_url,omitempty"` // 文件地址
ResponseBytes []byte `json:"-"`
TotalTime int64 `json:"-"`
}
type FileRetrieveRequest ¶
type FileRetrieveRequest struct {
FileId string `json:"file_id"`
}
type FileUploadRequest ¶
type FileUploadRequest struct {
File *multipart.FileHeader `json:"file"`
Purpose string `json:"purpose"`
ExpiresAfter ExpiresAfter `json:"expires_after"`
Model string `json:"-"`
}
type FunctionCall ¶
type FunctionDefinition ¶
type Functions ¶
type Functions struct {
// req
Text []FunctionDefinition `json:"text"`
}
type GenerationConfig ¶
type GenerationConfig struct {
StopSequences []string `json:"stopSequences,omitempty"`
CandidateCount int `json:"candidateCount,omitempty"`
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP float32 `json:"topP,omitempty"`
TopK int `json:"topK,omitempty"`
ResponseModalities []string `json:"responseModalities,omitempty"`
ImageConfig *ImageConfig `json:"imageConfig,omitempty"`
}
type GoogleChatCompletionReq ¶
type GoogleChatCompletionReq struct {
Contents []Content `json:"contents"`
GenerationConfig GenerationConfig `json:"generationConfig,omitempty"`
Tools any `json:"tools,omitempty"`
}
type GoogleChatCompletionRes ¶
type GoogleChatCompletionRes struct {
Candidates []Candidate `json:"candidates"`
UsageMetadata *UsageMetadata `json:"usageMetadata"`
ModelVersion string `json:"modelVersion"`
Error struct {
Code int `json:"code"`
Message string `json:"message"`
Status string `json:"status"`
Details []struct {
Type string `json:"@type"`
Reason string `json:"reason"`
Domain string `json:"domain"`
Metadata struct {
Service string `json:"service"`
} `json:"metadata"`
} `json:"details"`
} `json:"error"`
ResponseBytes []byte `json:"-"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
Err error `json:"-"`
}
type GoogleFile ¶
type GoogleFile struct {
Name string `json:"name"`
MimeType string `json:"mimeType"`
SizeBytes string `json:"sizeBytes"`
CreateTime time.Time `json:"createTime"`
UpdateTime time.Time `json:"updateTime"`
ExpirationTime time.Time `json:"expirationTime"`
Sha256Hash string `json:"sha256Hash"`
Uri string `json:"uri"`
State string `json:"state"`
VideoMetadata struct {
VideoDuration string `json:"videoDuration"`
} `json:"videoMetadata"`
Source string `json:"source"`
}
type GoogleFileListResponse ¶
type GoogleFileListResponse struct {
Files []GoogleFile `json:"files"`
TotalTime int64 `json:"-"`
}
type GoogleFileResponse ¶
type GoogleFileResponse struct {
File GoogleFile `json:"file"`
}
type GoogleImageGenerationReq ¶
type GoogleImageGenerationReq struct {
Contents []Content `json:"contents"`
Tools any `json:"tools,omitempty"`
GenerationConfig GenerationConfig `json:"generationConfig,omitempty"`
}
type Header ¶
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 ImageConfig ¶
type ImageEditRequest ¶
type ImageEditRequest struct {
Image []*multipart.FileHeader `json:"image,omitempty"`
Prompt string `json:"prompt,omitempty"`
Background string `json:"background,omitempty"`
Mask *multipart.FileHeader `json:"mask,omitempty"`
Model string `json:"model,omitempty"`
N int `json:"n,omitempty"`
Quality string `json:"quality,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
Size string `json:"size,omitempty"`
User string `json:"user,omitempty"`
AspectRatio string `json:"aspect_ratio,omitempty"`
}
type ImageGenerationRequest ¶
type ImageGenerationRequest struct {
Prompt string `json:"prompt,omitempty"`
Background string `json:"background,omitempty"`
Model string `json:"model,omitempty"`
Moderation string `json:"moderation,omitempty"`
N int `json:"n,omitempty"`
OutputCompression int `json:"output_compression,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
Quality string `json:"quality,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
Size string `json:"size,omitempty"`
Style string `json:"style,omitempty"`
User string `json:"user,omitempty"`
AspectRatio string `json:"aspect_ratio,omitempty"`
}
type ImageResponse ¶
type ImageResponse struct {
Created int64 `json:"created,omitempty"`
Data []ImageResponseData `json:"data,omitempty"`
Usage Usage `json:"usage,omitempty"`
TotalTime int64 `json:"-"`
}
type ImageResponseData ¶
type InlineData ¶
type Input ¶
type Input struct {
// 用户与模型的对话历史,list中的每个元素形式为{"role":角色, "content": 内容}。
// 角色当前可选值:system、user、assistant和tool。未来可以扩展到更多role。
Messages []ChatCompletionMessage `json:"messages"`
}
type InputTokensDetails ¶
type LogProb ¶
type LogProb struct {
Token string `json:"token"`
LogProb float64 `json:"logprob"`
Bytes []byte `json:"bytes,omitempty"`
TopLogProbs []TopLogProbs `json:"top_logprobs"`
}
type Message ¶
type Message struct {
// req
Text []ChatCompletionMessage `json:"text"`
}
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 MidjourneyResponse ¶
type ModerationRequest ¶
type ModerationResponse ¶
type OpenAIResponsesContent ¶
type OpenAIResponsesError ¶
type OpenAIResponsesFormat ¶
type OpenAIResponsesFormat struct {
Type string `json:"type"`
}
type OpenAIResponsesInput ¶
type OpenAIResponsesItem ¶
type OpenAIResponsesItem struct {
Id string `json:"id"`
Type string `json:"type"`
Status string `json:"status"`
Content []OpenAIResponsesContent `json:"content"`
Role string `json:"role"`
Arguments string `json:"arguments"`
CallId string `json:"call_id"`
Name string `json:"name"`
Summary []OpenAIResponsesSummary `json:"summary"`
}
type OpenAIResponsesOutput ¶
type OpenAIResponsesOutput struct {
Type string `json:"type"`
Id string `json:"id"`
Status string `json:"status,omitempty"`
Role string `json:"role,omitempty"`
Content []OpenAIResponsesContent `json:"content,omitempty"`
Summary []OpenAIResponsesSummary `json:"summary,omitempty"`
Arguments string `json:"arguments,omitempty"`
CallId string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
}
type OpenAIResponsesPart ¶
type OpenAIResponsesReq ¶
type OpenAIResponsesReq struct {
Model string `json:"model,omitempty"`
Input any `json:"input"`
Stream bool `json:"stream,omitempty"`
Background bool `json:"background,omitempty"`
Include any `json:"include,omitempty"`
Instructions string `json:"instructions,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
PreviousResponseId string `json:"previous_response_id,omitempty"`
Reasoning *OpenAIResponsesReasoning `json:"reasoning,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Store bool `json:"store,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
Text any `json:"text,omitempty"`
Tools any `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
TopP float32 `json:"top_p,omitempty"`
Truncation string `json:"truncation,omitempty"`
User string `json:"user,omitempty"`
}
type OpenAIResponsesRes ¶
type OpenAIResponsesRes struct {
Id string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
CreatedAt int64 `json:"created_at"`
Status string `json:"status"`
Background bool `json:"background"`
IncompleteDetails any `json:"incomplete_details"`
Instructions any `json:"instructions"`
MaxOutputTokens int `json:"max_output_tokens"`
Metadata map[string]string `json:"metadata"`
Output []OpenAIResponsesOutput `json:"output"`
ParallelToolCalls bool `json:"parallel_tool_calls"`
PreviousResponseId string `json:"previous_response_id"`
Reasoning OpenAIResponsesReasoning `json:"reasoning"`
ServiceTier string `json:"service_tier"`
Store bool `json:"store"`
Temperature float32 `json:"temperature"`
Text OpenAIResponsesText `json:"text"`
Tools any `json:"tools"`
ToolChoice string `json:"tool_choice"`
TopP float32 `json:"top_p"`
Truncation string `json:"truncation"`
User string `json:"user"`
Usage *Usage `json:"usage"`
Error *OpenAIResponsesError `json:"error"`
ResponseBytes []byte `json:"-"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
Err error `json:"-"`
}
type OpenAIResponsesResponse ¶
type OpenAIResponsesResponse struct {
Id string `json:"id"`
Object string `json:"object"`
CreatedAt int64 `json:"created_at"`
Status string `json:"status"`
Background bool `json:"background"`
IncompleteDetails any `json:"incomplete_details"`
Instructions any `json:"instructions"`
MaxOutputTokens int `json:"max_output_tokens"`
Model string `json:"model"`
Output []OpenAIResponsesOutput `json:"output"`
ParallelToolCalls bool `json:"parallel_tool_calls"`
PreviousResponseId string `json:"previous_response_id"`
Reasoning OpenAIResponsesReasoning `json:"reasoning"`
ServiceTier string `json:"service_tier"`
Store bool `json:"store"`
Temperature float32 `json:"temperature"`
Text OpenAIResponsesText `json:"text"`
ToolChoice string `json:"tool_choice"`
Tools any `json:"tools"`
TopP float32 `json:"top_p"`
Truncation string `json:"truncation"`
User string `json:"user"`
Metadata map[string]string `json:"metadata"`
Usage *Usage `json:"usage"`
Error *OpenAIResponsesError `json:"error"`
}
type OpenAIResponsesStreamRes ¶
type OpenAIResponsesStreamRes struct {
Type string `json:"type"`
SequenceNumber int `json:"sequence_number"`
Response OpenAIResponsesResponse `json:"response"`
OutputIndex int `json:"output_index"`
ContentIndex int `json:"content_index"`
ItemId string `json:"item_id"`
Item OpenAIResponsesItem `json:"item"`
Delta string `json:"delta"`
Part OpenAIResponsesPart `json:"part"`
Arguments string `json:"arguments"`
SSEEvent string `json:"-"`
ResponseBytes []byte `json:"-"`
ConnTime int64 `json:"-"`
Duration int64 `json:"-"`
TotalTime int64 `json:"-"`
Err error `json:"-"`
}
type OpenAIResponsesSummary ¶
type OpenAIResponsesText ¶
type OpenAIResponsesText struct {
Format OpenAIResponsesFormat `json:"format"`
}
type Output ¶
type Output struct {
// 包含本次请求的算法输出内容。
Text string `json:"text"`
// 有三种情况:正在生成时为null,生成结束时如果由于停止token导致则为stop,生成结束时如果因为生成长度过长导致则为length。
FinishReason string `json:"finish_reason"`
// 入参result_format=message时候的返回值
Choices []ChatCompletionChoice `json:"choices"`
}
type OutputExpiresAfter ¶
type OutputTokensDetails ¶
type OutputTokensDetails struct {
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
}
type Parameters ¶
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 any `json:"tools,omitempty"`
}
type Part ¶
type Part struct {
Text string `json:"text,omitempty"`
InlineData *InlineData `json:"inlineData,omitempty"`
FileData *FileData `json:"fileData,omitempty"`
FunctionCall any `json:"functionCall,omitempty"`
FunctionResponse any `json:"functionResponse,omitempty"`
ThoughtSignature any `json:"thoughtSignature,omitempty"`
}
type Payload ¶
type Payload struct {
// req
Message *Message `json:"message,omitempty"`
Functions *Functions `json:"functions,omitempty"`
// res
Choices *Choices `json:"choices,omitempty"`
Usage *XfyunUsage `json:"usage,omitempty"`
}
type PromptAnnotation ¶
type PromptAnnotation struct {
PromptIndex int `json:"prompt_index,omitempty"`
ContentFilterResults ContentFilterResults `json:"content_filter_results,omitempty"`
}
type PromptTokensDetails ¶
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 RealtimeRequest ¶
type RealtimeResponse ¶
type RequestCounts ¶
type SafetyRating ¶
type SearchInfo ¶
type SearchInfo struct {
SearchResults []SearchResult `json:"search_results,omitempty"` // 搜索结果列表
}
type SearchResult ¶
type Segment ¶
type Segment struct {
Id int `json:"id"`
Seek int `json:"seek"`
Start float64 `json:"start"`
End float64 `json:"end"`
Text string `json:"text"`
Tokens []int `json:"tokens"`
Temperature float64 `json:"temperature"`
AvgLogprob float64 `json:"avg_logprob"`
CompressionRatio float64 `json:"compression_ratio"`
NoSpeechProb float64 `json:"no_speech_prob"`
Transient bool `json:"transient"`
}
type SpeechRequest ¶
type SpeechResponse ¶
type StreamOptions ¶
type StreamOptions struct {
IncludeUsage bool `json:"include_usage,omitempty"`
}
type Text ¶
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 *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 ToolCall ¶
type ToolCall struct {
Index *int `json:"index,omitempty"`
Id string `json:"id,omitempty"`
Type string `json:"type"`
Function FunctionCall `json:"function"`
}
type TopLogProbs ¶
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptTokensDetails PromptTokensDetails `json:"prompt_tokens_details,omitempty"`
CompletionTokensDetails CompletionTokensDetails `json:"completion_tokens_details,omitempty"`
SearchTokens int `json:"search_tokens,omitempty"`
CacheCreationInputTokens int `json:"cache_creation_input_tokens,omitempty"`
CacheReadInputTokens int `json:"cache_read_input_tokens,omitempty"`
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
InputTokensDetails InputTokensDetails `json:"input_tokens_details,omitempty"`
OutputTokensDetails OutputTokensDetails `json:"output_tokens_details,omitempty"`
}
type UsageMetadata ¶
type UsageMetadata struct {
PromptTokenCount int `json:"promptTokenCount"`
CandidatesTokenCount int `json:"candidatesTokenCount"`
TotalTokenCount int `json:"totalTokenCount"`
PromptTokensDetails []struct {
Modality string `json:"modality"`
TokenCount int `json:"tokenCount"`
} `json:"promptTokensDetails"`
CandidatesTokensDetails []struct {
Modality string `json:"modality"`
TokenCount int `json:"tokenCount"`
} `json:"candidatesTokensDetails"`
ThoughtsTokenCount int `json:"thoughtsTokenCount"`
}
type VideoContentRequest ¶
type VideoContentResponse ¶
type VideoCreateRequest ¶
type VideoDeleteRequest ¶
type VideoDeleteRequest struct {
VideoId string `json:"video_id"`
}
type VideoError ¶
type VideoJobResponse ¶
type VideoJobResponse struct {
Id string `json:"id"`
Object string `json:"object"`
Model string `json:"model"`
Status string `json:"status"`
Progress int `json:"progress"`
CreatedAt int64 `json:"created_at"`
CompletedAt *int64 `json:"completed_at"`
ExpiresAt *int64 `json:"expires_at"`
Size string `json:"size"`
Prompt string `json:"prompt"`
Seconds string `json:"seconds"`
RemixedFromVideoId *string `json:"remixed_from_video_id"`
VideoUrl string `json:"video_url,omitempty"`
Deleted bool `json:"deleted,omitempty"`
Error *VideoError `json:"error"`
Usage *Usage `json:"usage,omitempty"`
ResponseBytes []byte `json:"-"`
TotalTime int64 `json:"-"`
}
type VideoListRequest ¶
type VideoListResponse ¶
type VideoRemixRequest ¶
type VideoRetrieveRequest ¶
type VideoRetrieveRequest struct {
VideoId string `json:"video_id"`
}
type VolcVideoContent ¶ added in v2.3.0
type VolcVideoContent struct {
Type string `json:"type"` // text, image_url, video_url, audio_url, draft_task
Text string `json:"text,omitempty"` // type=text 时的文本提示词
ImageUrl *VolcVideoMediaUrl `json:"image_url,omitempty"` // type=image_url 时的图片对象
VideoUrl *VolcVideoMediaUrl `json:"video_url,omitempty"` // type=video_url 时的视频对象
AudioUrl *VolcVideoMediaUrl `json:"audio_url,omitempty"` // type=audio_url 时的音频对象
DraftTask *VolcVideoDraftTask `json:"draft_task,omitempty"` // type=draft_task 时的样片任务
Role string `json:"role,omitempty"` // first_frame, last_frame, reference_image, reference_video, reference_audio
}
VolcVideoContent 输入给模型的内容项
type VolcVideoContentResult ¶ added in v2.3.0
type VolcVideoContentResult struct {
VideoUrl string `json:"video_url"` // 生成视频 URL
LastFrameUrl string `json:"last_frame_url,omitempty"` // 尾帧图像 URL
}
VolcVideoContentResult 视频生成输出内容
type VolcVideoCreateReq ¶ added in v2.3.0
type VolcVideoCreateReq struct {
Model string `json:"model"` // 模型 ID
Content []VolcVideoContent `json:"content"` // 输入内容(文本/图片/视频/音频/样片)
CallbackUrl string `json:"callback_url,omitempty"` // 回调通知地址
ReturnLastFrame *bool `json:"return_last_frame,omitempty"` // 是否返回尾帧图像
ServiceTier string `json:"service_tier,omitempty"` // default / flex
ExecutionExpiresAfter *int `json:"execution_expires_after,omitempty"` // 任务超时阈值(秒)
GenerateAudio *bool `json:"generate_audio,omitempty"` // 是否生成有声视频
Draft *bool `json:"draft,omitempty"` // 是否开启样片模式
Tools []VolcVideoTool `json:"tools,omitempty"` // 工具配置
SafetyIdentifier string `json:"safety_identifier,omitempty"` // 终端用户标识
Resolution string `json:"resolution,omitempty"` // 480p / 720p / 1080p
Ratio string `json:"ratio,omitempty"` // 16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9 / adaptive
Duration *int `json:"duration,omitempty"` // 视频时长(秒)
Frames *int `json:"frames,omitempty"` // 视频帧数
Seed *int64 `json:"seed,omitempty"` // 随机种子
CameraFixed *bool `json:"camera_fixed,omitempty"` // 是否固定摄像头
Watermark *bool `json:"watermark,omitempty"` // 是否含水印
}
VolcVideoCreateReq 创建视频生成任务请求
type VolcVideoDeleteReq ¶ added in v2.3.0
type VolcVideoDeleteReq struct {
TaskId string `json:"task_id" in:"path"`
}
VolcVideoDeleteReq 取消或删除视频任务请求参数
type VolcVideoDraftTask ¶ added in v2.3.0
type VolcVideoDraftTask struct {
Id string `json:"id"` // 样片任务 ID
}
VolcVideoDraftTask 样片任务
type VolcVideoError ¶ added in v2.3.0
VolcVideoError 错误信息
type VolcVideoListReq ¶ added in v2.3.0
type VolcVideoListReq struct {
PageNum *int `json:"page_num,omitempty"`
PageSize *int `json:"page_size,omitempty"`
FilterStatus string `json:"filter.status,omitempty"`
FilterTaskIds string `json:"filter.task_ids,omitempty"`
FilterModel string `json:"filter.model,omitempty"`
FilterServiceTier string `json:"filter.service_tier,omitempty"`
}
VolcVideoListReq 查询视频任务列表请求参数(Query String)
type VolcVideoListRes ¶ added in v2.3.0
type VolcVideoListRes struct {
Items []*VolcVideoTaskRes `json:"items"`
Total int `json:"total"`
}
VolcVideoListRes 查询视频任务列表响应
type VolcVideoMediaUrl ¶ added in v2.3.0
type VolcVideoMediaUrl struct {
Url string `json:"url"` // URL / Base64 编码 / 素材 ID(asset://xxx)
}
VolcVideoMediaUrl 媒体 URL 对象(图片/视频/音频共用)
type VolcVideoRetrieveReq ¶ added in v2.3.0
type VolcVideoRetrieveReq struct {
TaskId string `json:"task_id" in:"path"`
}
VolcVideoRetrieveReq 查询单个视频任务请求参数
type VolcVideoTaskRes ¶ added in v2.3.0
type VolcVideoTaskRes struct {
Id string `json:"id"`
Model string `json:"model"`
Status string `json:"status"`
Error *VolcVideoError `json:"error"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
Content *VolcVideoContentResult `json:"content"`
Seed *int64 `json:"seed,omitempty"`
Resolution string `json:"resolution,omitempty"`
Ratio string `json:"ratio,omitempty"`
Duration *int `json:"duration,omitempty"`
Frames *int `json:"frames,omitempty"`
FramesPerSecond *int `json:"framespersecond,omitempty"`
GenerateAudio *bool `json:"generate_audio,omitempty"`
Tools []VolcVideoTool `json:"tools,omitempty"`
SafetyIdentifier string `json:"safety_identifier,omitempty"`
Draft *bool `json:"draft,omitempty"`
DraftTaskId string `json:"draft_task_id,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
ExecutionExpiresAfter int `json:"execution_expires_after,omitempty"`
Usage *VolcVideoUsage `json:"usage,omitempty"`
}
VolcVideoTaskRes 视频生成任务响应(查询/创建共用)
type VolcVideoTool ¶ added in v2.3.0
type VolcVideoTool struct {
Type string `json:"type"` // web_search
}
VolcVideoTool 工具配置
type VolcVideoToolUsage ¶ added in v2.3.0
type VolcVideoToolUsage struct {
WebSearch int `json:"web_search,omitempty"` // 联网搜索次数
}
VolcVideoToolUsage 工具用量
type VolcVideoUsage ¶ added in v2.3.0
type VolcVideoUsage struct {
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
ToolUsage *VolcVideoToolUsage `json:"tool_usage,omitempty"`
}
VolcVideoUsage token 用量
type XfyunChatCompletionReq ¶
type XfyunChatCompletionRes ¶
type XfyunUsage ¶
type XfyunUsage struct {
// res
Text *Text `json:"text,omitempty"`
}
type ZhipuAIChatCompletionReq ¶
type ZhipuAIChatCompletionReq struct {
// 所要调用的模型编码
Model string `json:"model"`
// 调用语言模型时,将当前对话信息列表作为提示输入给模型
// 按照 {"role": "user", "content": "你好"} 的json 数组形式进行传参
// 可能的消息类型包括 System message、User message、Assistant message 和 Tool message。
Messages []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 any `json:"tools,omitempty"`
// 用于控制模型是如何选择要调用的函数,仅当工具类型为function时补充。默认为auto,当前仅支持auto
ToolChoice any `json:"tool_choice,omitempty"`
// 终端用户的唯一ID,协助平台对终端用户的违规行为、生成违法及不良信息或其他滥用行为进行干预。ID长度要求:最少6个字符,最多128个字符。
UserId string `json:"user_id,omitempty"`
}
type ZhipuAIChatCompletionRes ¶
type ZhipuAIChatCompletionRes struct {
// 任务ID
Id string `json:"id"`
// 请求创建时间,是以秒为单位的 Unix 时间戳
Created int64 `json:"created"`
// 模型名称
Model string `json:"model"`
// 当前对话的模型输出内容
Choices []ChatCompletionChoice `json:"choices"`
// 结束时返回本次模型调用的 tokens 数量统计。
Usage *Usage `json:"usage"`
// 当failed时会有错误信息
Error ZhipuAIError `json:"error"`
}
type ZhipuAIError ¶
type ZhipuAIErrorResponse ¶
type ZhipuAIErrorResponse struct {
Error *ZhipuAIError `json:"error,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.