dto

package
v0.10.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotifyTypeQuotaExceed   = "quota_exceed"
	NotifyTypeChannelUpdate = "channel_update"
	NotifyTypeChannelTest   = "channel_test"
)
View Source
const (
	ContentTypeText       = "text"
	ContentTypeImageURL   = "image_url"
	ContentTypeInputAudio = "input_audio"
	ContentTypeFile       = "file"
	ContentTypeVideoUrl   = "video_url" // 阿里百炼视频识别

)
View Source
const (
	BuildInToolWebSearchPreview = "web_search_preview"
	BuildInToolFileSearch       = "file_search"
)
View Source
const (
	ResponsesOutputTypeItemAdded = "response.output_item.added"
	ResponsesOutputTypeItemDone  = "response.output_item.done"
)
View Source
const (
	VideoStatusUnknown    = "unknown"
	VideoStatusQueued     = "queued"
	VideoStatusInProgress = "in_progress"
	VideoStatusCompleted  = "completed"
	VideoStatusFailed     = "failed"
)
View Source
const (
	RealtimeEventTypeError              = "error"
	RealtimeEventTypeSessionUpdate      = "session.update"
	RealtimeEventTypeConversationCreate = "conversation.item.create"
	RealtimeEventTypeResponseCreate     = "response.create"
	RealtimeEventInputAudioBufferAppend = "input_audio_buffer.append"
)
View Source
const (
	RealtimeEventTypeResponseDone                   = "response.done"
	RealtimeEventTypeSessionUpdated                 = "session.updated"
	RealtimeEventTypeSessionCreated                 = "session.created"
	RealtimeEventResponseAudioDelta                 = "response.audio.delta"
	RealtimeEventResponseAudioTranscriptionDelta    = "response.audio_transcript.delta"
	RealtimeEventResponseFunctionCallArgumentsDelta = "response.function_call_arguments.delta"
	RealtimeEventResponseFunctionCallArgumentsDone  = "response.function_call_arguments.done"
	RealtimeEventConversationItemCreated            = "conversation.item.created"
)
View Source
const (
	BuildInCallWebSearchCall = "web_search_call"
)
View Source
const ContentValueParam = "{{value}}"
View Source
const CustomType = "custom"
View Source
const (
	ResponsesOutputTypeImageGenerationCall = "image_generation_call"
)
View Source
const TaskSuccessCode = "success"

Variables

View Source
var (
	NotifyTypeEmail   = "email"   // Email 邮件
	NotifyTypeWebhook = "webhook" // Webhook
	NotifyTypeBark    = "bark"    // Bark 推送
	NotifyTypeGotify  = "gotify"  // Gotify 推送
)

Functions

func GetJSONFieldNames

func GetJSONFieldNames(t reflect.Type) map[string]struct{}

func GetOpenAIError

func GetOpenAIError(errorField any) *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

func ProcessTools

func ProcessTools(tools []any) ([]*Tool, []*ClaudeWebSearchTool)

ProcessTools 处理工具列表,支持类型断言

Types

type ActionButton

type ActionButton struct {
	CustomId any `json:"customId"`
	Emoji    any `json:"emoji"`
	Label    any `json:"label"`
	Type     any `json:"type"`
	Style    any `json:"style"`
}

type AnthropicModel

type AnthropicModel struct {
	ID          string `json:"id"`
	CreatedAt   string `json:"created_at"`
	DisplayName string `json:"display_name"`
	Type        string `json:"type"`
}

type AudioRequest

type AudioRequest struct {
	Model          string          `json:"model"`
	Input          string          `json:"input"`
	Voice          string          `json:"voice"`
	Instructions   string          `json:"instructions,omitempty"`
	ResponseFormat string          `json:"response_format,omitempty"`
	Speed          float64         `json:"speed,omitempty"`
	StreamFormat   string          `json:"stream_format,omitempty"`
	Metadata       json.RawMessage `json:"metadata,omitempty"`
}

func (*AudioRequest) GetTokenCountMeta

func (r *AudioRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*AudioRequest) IsStream

func (r *AudioRequest) IsStream(c *gin.Context) bool

func (*AudioRequest) SetModelName

func (r *AudioRequest) SetModelName(modelName string)

type AudioResponse

type AudioResponse struct {
	Text string `json:"text"`
}

type AwsKeyType

type AwsKeyType string
const (
	AwsKeyTypeAKSK   AwsKeyType = "ak_sk" // 默认
	AwsKeyTypeApiKey AwsKeyType = "api_key"
)

type BaseRequest

type BaseRequest struct {
}

func (*BaseRequest) GetTokenCountMeta

func (b *BaseRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*BaseRequest) IsStream

func (b *BaseRequest) IsStream(c *gin.Context) bool

func (*BaseRequest) SetModelName

func (b *BaseRequest) SetModelName(modelName string)

type BoolValue

type BoolValue bool

func (BoolValue) MarshalJSON

func (b BoolValue) MarshalJSON() ([]byte, error)

func (*BoolValue) UnmarshalJSON

func (b *BoolValue) UnmarshalJSON(data []byte) error

type ChannelOtherSettings

type ChannelOtherSettings struct {
	AzureResponsesVersion string        `json:"azure_responses_version,omitempty"`
	VertexKeyType         VertexKeyType `json:"vertex_key_type,omitempty"` // "json" or "api_key"
	OpenRouterEnterprise  *bool         `json:"openrouter_enterprise,omitempty"`
	AllowServiceTier      bool          `json:"allow_service_tier,omitempty"`      // 是否允许 service_tier 透传(默认过滤以避免额外计费)
	DisableStore          bool          `json:"disable_store,omitempty"`           // 是否禁用 store 透传(默认允许透传,禁用后可能导致 Codex 无法使用)
	AllowSafetyIdentifier bool          `json:"allow_safety_identifier,omitempty"` // 是否允许 safety_identifier 透传(默认过滤以保护用户隐私)
	AwsKeyType            AwsKeyType    `json:"aws_key_type,omitempty"`
}

func (*ChannelOtherSettings) IsOpenRouterEnterprise

func (s *ChannelOtherSettings) IsOpenRouterEnterprise() bool

type ChannelSettings

type ChannelSettings struct {
	ForceFormat            bool   `json:"force_format,omitempty"`
	ThinkingToContent      bool   `json:"thinking_to_content,omitempty"`
	Proxy                  string `json:"proxy"`
	PassThroughBodyEnabled bool   `json:"pass_through_body_enabled,omitempty"`
	SystemPrompt           string `json:"system_prompt,omitempty"`
	SystemPromptOverride   bool   `json:"system_prompt_override,omitempty"`
}

type ChatCompletionsStreamResponse

type ChatCompletionsStreamResponse struct {
	Id                string                                `json:"id"`
	Object            string                                `json:"object"`
	Created           int64                                 `json:"created"`
	Model             string                                `json:"model"`
	SystemFingerprint *string                               `json:"system_fingerprint"`
	Choices           []ChatCompletionsStreamResponseChoice `json:"choices"`
	Usage             *Usage                                `json:"usage"`
}

func (*ChatCompletionsStreamResponse) ClearToolCalls

func (c *ChatCompletionsStreamResponse) ClearToolCalls()

func (*ChatCompletionsStreamResponse) Copy

func (*ChatCompletionsStreamResponse) GetFirstToolCall

func (c *ChatCompletionsStreamResponse) GetFirstToolCall() *ToolCallResponse

func (*ChatCompletionsStreamResponse) GetSystemFingerprint

func (c *ChatCompletionsStreamResponse) GetSystemFingerprint() string

func (*ChatCompletionsStreamResponse) IsFinished

func (c *ChatCompletionsStreamResponse) IsFinished() bool

func (*ChatCompletionsStreamResponse) IsToolCall

func (c *ChatCompletionsStreamResponse) IsToolCall() bool

func (*ChatCompletionsStreamResponse) SetSystemFingerprint

func (c *ChatCompletionsStreamResponse) SetSystemFingerprint(s string)

type ChatCompletionsStreamResponseChoice

type ChatCompletionsStreamResponseChoice struct {
	Delta        ChatCompletionsStreamResponseChoiceDelta `json:"delta,omitempty"`
	Logprobs     *any                                     `json:"logprobs"`
	FinishReason *string                                  `json:"finish_reason"`
	Index        int                                      `json:"index"`
}

type ChatCompletionsStreamResponseChoiceDelta

type ChatCompletionsStreamResponseChoiceDelta struct {
	Content          *string            `json:"content,omitempty"`
	ReasoningContent *string            `json:"reasoning_content,omitempty"`
	Reasoning        *string            `json:"reasoning,omitempty"`
	Role             string             `json:"role,omitempty"`
	ToolCalls        []ToolCallResponse `json:"tool_calls,omitempty"`
}

func (*ChatCompletionsStreamResponseChoiceDelta) GetContentString

func (c *ChatCompletionsStreamResponseChoiceDelta) GetContentString() string

func (*ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent

func (c *ChatCompletionsStreamResponseChoiceDelta) GetReasoningContent() string

func (*ChatCompletionsStreamResponseChoiceDelta) SetContentString

func (c *ChatCompletionsStreamResponseChoiceDelta) SetContentString(s string)

func (*ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent

func (c *ChatCompletionsStreamResponseChoiceDelta) SetReasoningContent(s string)

type ChatCompletionsStreamResponseSimple

type ChatCompletionsStreamResponseSimple struct {
	Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
	Usage   *Usage                                `json:"usage"`
}

type ClaudeCacheCreationUsage

type ClaudeCacheCreationUsage struct {
	Ephemeral5mInputTokens int `json:"ephemeral_5m_input_tokens,omitempty"`
	Ephemeral1hInputTokens int `json:"ephemeral_1h_input_tokens,omitempty"`
}

type ClaudeErrorWithStatusCode

type ClaudeErrorWithStatusCode struct {
	Error      types.ClaudeError `json:"error"`
	StatusCode int               `json:"status_code"`
	LocalError bool
}

type ClaudeMediaMessage

type ClaudeMediaMessage struct {
	Type         string               `json:"type,omitempty"`
	Text         *string              `json:"text,omitempty"`
	Model        string               `json:"model,omitempty"`
	Source       *ClaudeMessageSource `json:"source,omitempty"`
	Usage        *ClaudeUsage         `json:"usage,omitempty"`
	StopReason   *string              `json:"stop_reason,omitempty"`
	PartialJson  *string              `json:"partial_json,omitempty"`
	Role         string               `json:"role,omitempty"`
	Thinking     *string              `json:"thinking,omitempty"`
	Signature    string               `json:"signature,omitempty"`
	Delta        string               `json:"delta,omitempty"`
	CacheControl json.RawMessage      `json:"cache_control,omitempty"`
	// tool_calls
	Id        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Input     any    `json:"input,omitempty"`
	Content   any    `json:"content,omitempty"`
	ToolUseId string `json:"tool_use_id,omitempty"`
}

func (*ClaudeMediaMessage) GetJsonRowString

func (c *ClaudeMediaMessage) GetJsonRowString() string

func (*ClaudeMediaMessage) GetStringContent

func (c *ClaudeMediaMessage) GetStringContent() string

func (*ClaudeMediaMessage) GetText

func (c *ClaudeMediaMessage) GetText() string

func (*ClaudeMediaMessage) IsStringContent

func (c *ClaudeMediaMessage) IsStringContent() bool

func (*ClaudeMediaMessage) ParseMediaContent

func (c *ClaudeMediaMessage) ParseMediaContent() []ClaudeMediaMessage

func (*ClaudeMediaMessage) SetContent

func (c *ClaudeMediaMessage) SetContent(content any)

func (*ClaudeMediaMessage) SetText

func (c *ClaudeMediaMessage) SetText(s string)

type ClaudeMessage

type ClaudeMessage struct {
	Role    string `json:"role"`
	Content any    `json:"content"`
}

func (*ClaudeMessage) GetStringContent

func (c *ClaudeMessage) GetStringContent() string

func (*ClaudeMessage) IsStringContent

func (c *ClaudeMessage) IsStringContent() bool

func (*ClaudeMessage) ParseContent

func (c *ClaudeMessage) ParseContent() ([]ClaudeMediaMessage, error)

func (*ClaudeMessage) SetContent

func (c *ClaudeMessage) SetContent(content any)

func (*ClaudeMessage) SetStringContent

func (c *ClaudeMessage) SetStringContent(content string)

type ClaudeMessageSource

type ClaudeMessageSource struct {
	Type      string `json:"type"`
	MediaType string `json:"media_type,omitempty"`
	Data      any    `json:"data,omitempty"`
	Url       string `json:"url,omitempty"`
}

type ClaudeMetadata

type ClaudeMetadata struct {
	UserId string `json:"user_id"`
}

type ClaudeRequest

type ClaudeRequest struct {
	Model             string          `json:"model"`
	Prompt            string          `json:"prompt,omitempty"`
	System            any             `json:"system,omitempty"`
	Messages          []ClaudeMessage `json:"messages,omitempty"`
	MaxTokens         uint            `json:"max_tokens,omitempty"`
	MaxTokensToSample uint            `json:"max_tokens_to_sample,omitempty"`
	StopSequences     []string        `json:"stop_sequences,omitempty"`
	Temperature       *float64        `json:"temperature,omitempty"`
	TopP              float64         `json:"top_p,omitempty"`
	TopK              int             `json:"top_k,omitempty"`
	Stream            bool            `json:"stream,omitempty"`
	Tools             any             `json:"tools,omitempty"`
	ContextManagement json.RawMessage `json:"context_management,omitempty"`
	OutputConfig      json.RawMessage `json:"output_config,omitempty"`
	OutputFormat      json.RawMessage `json:"output_format,omitempty"`
	Container         json.RawMessage `json:"container,omitempty"`
	ToolChoice        any             `json:"tool_choice,omitempty"`
	Thinking          *Thinking       `json:"thinking,omitempty"`
	McpServers        json.RawMessage `json:"mcp_servers,omitempty"`
	Metadata          json.RawMessage `json:"metadata,omitempty"`
	// 服务层级字段,用于指定 API 服务等级。允许透传可能导致实际计费高于预期,默认应过滤
	ServiceTier string `json:"service_tier,omitempty"`
}

func (*ClaudeRequest) AddTool

func (c *ClaudeRequest) AddTool(tool any)

AddTool 添加工具到请求中

func (*ClaudeRequest) GetStringSystem

func (c *ClaudeRequest) GetStringSystem() string

func (*ClaudeRequest) GetTokenCountMeta

func (c *ClaudeRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*ClaudeRequest) GetTools

func (c *ClaudeRequest) GetTools() []any

GetTools 获取工具列表

func (*ClaudeRequest) IsStream

func (c *ClaudeRequest) IsStream(ctx *gin.Context) bool

func (*ClaudeRequest) IsStringSystem

func (c *ClaudeRequest) IsStringSystem() bool

func (*ClaudeRequest) ParseSystem

func (c *ClaudeRequest) ParseSystem() []ClaudeMediaMessage

func (*ClaudeRequest) SearchToolNameByToolCallId

func (c *ClaudeRequest) SearchToolNameByToolCallId(toolCallId string) string

func (*ClaudeRequest) SetModelName

func (c *ClaudeRequest) SetModelName(modelName string)

func (*ClaudeRequest) SetStringSystem

func (c *ClaudeRequest) SetStringSystem(system string)

type ClaudeResponse

type ClaudeResponse struct {
	Id           string               `json:"id,omitempty"`
	Type         string               `json:"type"`
	Role         string               `json:"role,omitempty"`
	Content      []ClaudeMediaMessage `json:"content,omitempty"`
	Completion   string               `json:"completion,omitempty"`
	StopReason   string               `json:"stop_reason,omitempty"`
	Model        string               `json:"model,omitempty"`
	Error        any                  `json:"error,omitempty"`
	Usage        *ClaudeUsage         `json:"usage,omitempty"`
	Index        *int                 `json:"index,omitempty"`
	ContentBlock *ClaudeMediaMessage  `json:"content_block,omitempty"`
	Delta        *ClaudeMediaMessage  `json:"delta,omitempty"`
	Message      *ClaudeMediaMessage  `json:"message,omitempty"`
}

func (*ClaudeResponse) GetClaudeError

func (c *ClaudeResponse) GetClaudeError() *types.ClaudeError

GetClaudeError 从动态错误类型中提取ClaudeError结构

func (*ClaudeResponse) GetIndex

func (c *ClaudeResponse) GetIndex() int

get index

func (*ClaudeResponse) SetIndex

func (c *ClaudeResponse) SetIndex(i int)

set index

type ClaudeServerToolUse

type ClaudeServerToolUse struct {
	WebSearchRequests int `json:"web_search_requests"`
}

type ClaudeToolChoice

type ClaudeToolChoice struct {
	Type                   string `json:"type"`
	Name                   string `json:"name,omitempty"`
	DisableParallelToolUse bool   `json:"disable_parallel_tool_use,omitempty"`
}

type ClaudeUsage

type ClaudeUsage struct {
	InputTokens              int                       `json:"input_tokens"`
	CacheCreationInputTokens int                       `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int                       `json:"cache_read_input_tokens"`
	OutputTokens             int                       `json:"output_tokens"`
	CacheCreation            *ClaudeCacheCreationUsage `json:"cache_creation,omitempty"`
	// claude cache 1h
	ClaudeCacheCreation5mTokens int                  `json:"claude_cache_creation_5_m_tokens"`
	ClaudeCacheCreation1hTokens int                  `json:"claude_cache_creation_1_h_tokens"`
	ServerToolUse               *ClaudeServerToolUse `json:"server_tool_use,omitempty"`
}

func (*ClaudeUsage) GetCacheCreation1hTokens

func (u *ClaudeUsage) GetCacheCreation1hTokens() int

func (*ClaudeUsage) GetCacheCreation5mTokens

func (u *ClaudeUsage) GetCacheCreation5mTokens() int

func (*ClaudeUsage) GetCacheCreationTotalTokens

func (u *ClaudeUsage) GetCacheCreationTotalTokens() int

type ClaudeWebSearchTool

type ClaudeWebSearchTool struct {
	Type         string                       `json:"type"`
	Name         string                       `json:"name"`
	MaxUses      int                          `json:"max_uses,omitempty"`
	UserLocation *ClaudeWebSearchUserLocation `json:"user_location,omitempty"`
}

type ClaudeWebSearchUserLocation

type ClaudeWebSearchUserLocation struct {
	Type     string `json:"type"`
	Timezone string `json:"timezone,omitempty"`
	Country  string `json:"country,omitempty"`
	Region   string `json:"region,omitempty"`
	City     string `json:"city,omitempty"`
}

type CompletionsStreamResponse

type CompletionsStreamResponse struct {
	Choices []struct {
		Text         string `json:"text"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
}

type ContentEmbedding

type ContentEmbedding struct {
	Values []float64 `json:"values"`
}

type DifferenceItem

type DifferenceItem struct {
	Current    interface{}            `json:"current"`
	Upstreams  map[string]interface{} `json:"upstreams"`
	Confidence map[string]bool        `json:"confidence"`
}

type EmbeddingOptions

type EmbeddingOptions struct {
	Seed             int      `json:"seed,omitempty"`
	Temperature      *float64 `json:"temperature,omitempty"`
	TopK             int      `json:"top_k,omitempty"`
	TopP             *float64 `json:"top_p,omitempty"`
	FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
	PresencePenalty  *float64 `json:"presence_penalty,omitempty"`
	NumPredict       int      `json:"num_predict,omitempty"`
	NumCtx           int      `json:"num_ctx,omitempty"`
}

type EmbeddingRequest

type EmbeddingRequest struct {
	Model            string   `json:"model"`
	Input            any      `json:"input"`
	EncodingFormat   string   `json:"encoding_format,omitempty"`
	Dimensions       int      `json:"dimensions,omitempty"`
	User             string   `json:"user,omitempty"`
	Seed             float64  `json:"seed,omitempty"`
	Temperature      *float64 `json:"temperature,omitempty"`
	TopP             float64  `json:"top_p,omitempty"`
	FrequencyPenalty float64  `json:"frequency_penalty,omitempty"`
	PresencePenalty  float64  `json:"presence_penalty,omitempty"`
}

func (*EmbeddingRequest) GetTokenCountMeta

func (r *EmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*EmbeddingRequest) IsStream

func (r *EmbeddingRequest) IsStream(c *gin.Context) bool

func (*EmbeddingRequest) ParseInput

func (r *EmbeddingRequest) ParseInput() []string

func (*EmbeddingRequest) SetModelName

func (r *EmbeddingRequest) SetModelName(modelName string)

type EmbeddingResponse

type EmbeddingResponse struct {
	Object string                  `json:"object"`
	Data   []EmbeddingResponseItem `json:"data"`
	Model  string                  `json:"model"`
	Usage  `json:"usage"`
}

type EmbeddingResponseItem

type EmbeddingResponseItem struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float64 `json:"embedding"`
}

type FetchReq

type FetchReq struct {
	IDs []string `json:"ids"`
}

type FlexibleEmbeddingResponse

type FlexibleEmbeddingResponse struct {
	Object string                          `json:"object"`
	Data   []FlexibleEmbeddingResponseItem `json:"data"`
	Model  string                          `json:"model"`
	Usage  `json:"usage"`
}

type FlexibleEmbeddingResponseItem

type FlexibleEmbeddingResponseItem struct {
	Object    string `json:"object"`
	Index     int    `json:"index"`
	Embedding any    `json:"embedding"`
}

type FormatJsonSchema

type FormatJsonSchema struct {
	Description string          `json:"description,omitempty"`
	Name        string          `json:"name"`
	Schema      any             `json:"schema,omitempty"`
	Strict      json.RawMessage `json:"strict,omitempty"`
}

type FunctionCall

type FunctionCall struct {
	FunctionName string `json:"name"`
	Arguments    any    `json:"args"`
}

type FunctionCallingConfig

type FunctionCallingConfig struct {
	Mode                 FunctionCallingConfigMode `json:"mode,omitempty"`
	AllowedFunctionNames []string                  `json:"allowedFunctionNames,omitempty"`
}

type FunctionCallingConfigMode

type FunctionCallingConfigMode string

type FunctionRequest

type FunctionRequest struct {
	Description string `json:"description,omitempty"`
	Name        string `json:"name"`
	Parameters  any    `json:"parameters,omitempty"`
	Arguments   string `json:"arguments,omitempty"`
}

type FunctionResponse

type FunctionResponse struct {
	Description string `json:"description,omitempty"`
	Name        string `json:"name,omitempty"`
	// call function with arguments in JSON format
	Parameters any    `json:"parameters,omitempty"` // request
	Arguments  string `json:"arguments"`            // response
}

type GeminiBatchEmbeddingRequest

type GeminiBatchEmbeddingRequest struct {
	Requests []*GeminiEmbeddingRequest `json:"requests"`
}

func (*GeminiBatchEmbeddingRequest) GetTokenCountMeta

func (r *GeminiBatchEmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiBatchEmbeddingRequest) IsStream

func (r *GeminiBatchEmbeddingRequest) IsStream(c *gin.Context) bool

func (*GeminiBatchEmbeddingRequest) SetModelName

func (r *GeminiBatchEmbeddingRequest) SetModelName(modelName string)

type GeminiBatchEmbeddingResponse

type GeminiBatchEmbeddingResponse struct {
	Embeddings []*ContentEmbedding `json:"embeddings"`
}

type GeminiChatCandidate

type GeminiChatCandidate struct {
	Content       GeminiChatContent        `json:"content"`
	FinishReason  *string                  `json:"finishReason"`
	Index         int64                    `json:"index"`
	SafetyRatings []GeminiChatSafetyRating `json:"safetyRatings"`
}

type GeminiChatContent

type GeminiChatContent struct {
	Role  string       `json:"role,omitempty"`
	Parts []GeminiPart `json:"parts"`
}

type GeminiChatGenerationConfig

type GeminiChatGenerationConfig struct {
	Temperature        *float64              `json:"temperature,omitempty"`
	TopP               float64               `json:"topP,omitempty"`
	TopK               float64               `json:"topK,omitempty"`
	MaxOutputTokens    uint                  `json:"maxOutputTokens,omitempty"`
	CandidateCount     int                   `json:"candidateCount,omitempty"`
	StopSequences      []string              `json:"stopSequences,omitempty"`
	ResponseMimeType   string                `json:"responseMimeType,omitempty"`
	ResponseSchema     any                   `json:"responseSchema,omitempty"`
	ResponseJsonSchema json.RawMessage       `json:"responseJsonSchema,omitempty"`
	PresencePenalty    *float32              `json:"presencePenalty,omitempty"`
	FrequencyPenalty   *float32              `json:"frequencyPenalty,omitempty"`
	ResponseLogprobs   bool                  `json:"responseLogprobs,omitempty"`
	Logprobs           *int32                `json:"logprobs,omitempty"`
	MediaResolution    MediaResolution       `json:"mediaResolution,omitempty"`
	Seed               int64                 `json:"seed,omitempty"`
	ResponseModalities []string              `json:"responseModalities,omitempty"`
	ThinkingConfig     *GeminiThinkingConfig `json:"thinkingConfig,omitempty"`
	SpeechConfig       json.RawMessage       `json:"speechConfig,omitempty"` // RawMessage to allow flexible speech config
	ImageConfig        json.RawMessage       `json:"imageConfig,omitempty"`  // RawMessage to allow flexible image config
}

func (*GeminiChatGenerationConfig) UnmarshalJSON

func (c *GeminiChatGenerationConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiChatGenerationConfig to accept both snake_case and camelCase fields.

type GeminiChatPromptFeedback

type GeminiChatPromptFeedback struct {
	SafetyRatings []GeminiChatSafetyRating `json:"safetyRatings"`
	BlockReason   *string                  `json:"blockReason,omitempty"`
}

type GeminiChatRequest

type GeminiChatRequest struct {
	Requests           []GeminiChatRequest        `json:"requests,omitempty"` // For batch requests
	Contents           []GeminiChatContent        `json:"contents"`
	SafetySettings     []GeminiChatSafetySettings `json:"safetySettings,omitempty"`
	GenerationConfig   GeminiChatGenerationConfig `json:"generationConfig,omitempty"`
	Tools              json.RawMessage            `json:"tools,omitempty"`
	ToolConfig         *ToolConfig                `json:"toolConfig,omitempty"`
	SystemInstructions *GeminiChatContent         `json:"systemInstruction,omitempty"`
	CachedContent      string                     `json:"cachedContent,omitempty"`
}

func (*GeminiChatRequest) GetTokenCountMeta

func (r *GeminiChatRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiChatRequest) GetTools

func (r *GeminiChatRequest) GetTools() []GeminiChatTool

func (*GeminiChatRequest) IsStream

func (r *GeminiChatRequest) IsStream(c *gin.Context) bool

func (*GeminiChatRequest) SetModelName

func (r *GeminiChatRequest) SetModelName(modelName string)

func (*GeminiChatRequest) SetTools

func (r *GeminiChatRequest) SetTools(tools []GeminiChatTool)

func (*GeminiChatRequest) UnmarshalJSON

func (r *GeminiChatRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiChatRequest to accept both snake_case and camelCase fields.

type GeminiChatResponse

type GeminiChatResponse struct {
	Candidates     []GeminiChatCandidate     `json:"candidates"`
	PromptFeedback *GeminiChatPromptFeedback `json:"promptFeedback,omitempty"`
	UsageMetadata  GeminiUsageMetadata       `json:"usageMetadata"`
}

type GeminiChatSafetyRating

type GeminiChatSafetyRating struct {
	Category    string `json:"category"`
	Probability string `json:"probability"`
}

type GeminiChatSafetySettings

type GeminiChatSafetySettings struct {
	Category  string `json:"category"`
	Threshold string `json:"threshold"`
}

type GeminiChatTool

type GeminiChatTool struct {
	GoogleSearch          any `json:"googleSearch,omitempty"`
	GoogleSearchRetrieval any `json:"googleSearchRetrieval,omitempty"`
	CodeExecution         any `json:"codeExecution,omitempty"`
	FunctionDeclarations  any `json:"functionDeclarations,omitempty"`
	URLContext            any `json:"urlContext,omitempty"`
}

type GeminiEmbeddingRequest

type GeminiEmbeddingRequest struct {
	Model                string            `json:"model,omitempty"`
	Content              GeminiChatContent `json:"content"`
	TaskType             string            `json:"taskType,omitempty"`
	Title                string            `json:"title,omitempty"`
	OutputDimensionality int               `json:"outputDimensionality,omitempty"`
}

Embedding related structs

func (*GeminiEmbeddingRequest) GetTokenCountMeta

func (r *GeminiEmbeddingRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeminiEmbeddingRequest) IsStream

func (r *GeminiEmbeddingRequest) IsStream(c *gin.Context) bool

func (*GeminiEmbeddingRequest) SetModelName

func (r *GeminiEmbeddingRequest) SetModelName(modelName string)

type GeminiEmbeddingResponse

type GeminiEmbeddingResponse struct {
	Embedding ContentEmbedding `json:"embedding"`
}

type GeminiFileData

type GeminiFileData struct {
	MimeType string `json:"mimeType,omitempty"`
	FileUri  string `json:"fileUri,omitempty"`
}

type GeminiFunctionResponse

type GeminiFunctionResponse struct {
	Name         string                 `json:"name"`
	Response     map[string]interface{} `json:"response"`
	WillContinue json.RawMessage        `json:"willContinue,omitempty"`
	Scheduling   json.RawMessage        `json:"scheduling,omitempty"`
	Parts        json.RawMessage        `json:"parts,omitempty"`
	ID           json.RawMessage        `json:"id,omitempty"`
}

type GeminiImageInstance

type GeminiImageInstance struct {
	Prompt string `json:"prompt"`
}

type GeminiImageParameters

type GeminiImageParameters struct {
	SampleCount      int    `json:"sampleCount,omitempty"`
	AspectRatio      string `json:"aspectRatio,omitempty"`
	PersonGeneration string `json:"personGeneration,omitempty"`
	ImageSize        string `json:"imageSize,omitempty"`
}

type GeminiImagePrediction

type GeminiImagePrediction struct {
	MimeType           string `json:"mimeType"`
	BytesBase64Encoded string `json:"bytesBase64Encoded"`
	RaiFilteredReason  string `json:"raiFilteredReason,omitempty"`
	SafetyAttributes   any    `json:"safetyAttributes,omitempty"`
}

type GeminiImageRequest

type GeminiImageRequest struct {
	Instances  []GeminiImageInstance `json:"instances"`
	Parameters GeminiImageParameters `json:"parameters"`
}

Imagen related structs

type GeminiImageResponse

type GeminiImageResponse struct {
	Predictions []GeminiImagePrediction `json:"predictions"`
}

type GeminiInlineData

type GeminiInlineData struct {
	MimeType string `json:"mimeType"`
	Data     string `json:"data"`
}

func (*GeminiInlineData) UnmarshalJSON

func (g *GeminiInlineData) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler for GeminiInlineData to support snake_case and camelCase for MimeType

type GeminiModel

type GeminiModel struct {
	Name                       interface{}   `json:"name"`
	BaseModelId                interface{}   `json:"baseModelId"`
	Version                    interface{}   `json:"version"`
	DisplayName                interface{}   `json:"displayName"`
	Description                interface{}   `json:"description"`
	InputTokenLimit            interface{}   `json:"inputTokenLimit"`
	OutputTokenLimit           interface{}   `json:"outputTokenLimit"`
	SupportedGenerationMethods []interface{} `json:"supportedGenerationMethods"`
	Thinking                   interface{}   `json:"thinking"`
	Temperature                interface{}   `json:"temperature"`
	MaxTemperature             interface{}   `json:"maxTemperature"`
	TopP                       interface{}   `json:"topP"`
	TopK                       interface{}   `json:"topK"`
}

type GeminiPart

type GeminiPart struct {
	Text             string                  `json:"text,omitempty"`
	Thought          bool                    `json:"thought,omitempty"`
	InlineData       *GeminiInlineData       `json:"inlineData,omitempty"`
	FunctionCall     *FunctionCall           `json:"functionCall,omitempty"`
	ThoughtSignature json.RawMessage         `json:"thoughtSignature,omitempty"`
	FunctionResponse *GeminiFunctionResponse `json:"functionResponse,omitempty"`
	// Optional. Media resolution for the input media.
	MediaResolution     json.RawMessage                `json:"mediaResolution,omitempty"`
	VideoMetadata       json.RawMessage                `json:"videoMetadata,omitempty"`
	FileData            *GeminiFileData                `json:"fileData,omitempty"`
	ExecutableCode      *GeminiPartExecutableCode      `json:"executableCode,omitempty"`
	CodeExecutionResult *GeminiPartCodeExecutionResult `json:"codeExecutionResult,omitempty"`
}

func (*GeminiPart) UnmarshalJSON

func (p *GeminiPart) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaler for GeminiPart to support snake_case and camelCase for InlineData

type GeminiPartCodeExecutionResult

type GeminiPartCodeExecutionResult struct {
	Outcome string `json:"outcome,omitempty"`
	Output  string `json:"output,omitempty"`
}

type GeminiPartExecutableCode

type GeminiPartExecutableCode struct {
	Language string `json:"language,omitempty"`
	Code     string `json:"code,omitempty"`
}

type GeminiPromptTokensDetails

type GeminiPromptTokensDetails struct {
	Modality   string `json:"modality"`
	TokenCount int    `json:"tokenCount"`
}

type GeminiThinkingConfig

type GeminiThinkingConfig struct {
	IncludeThoughts bool `json:"includeThoughts,omitempty"`
	ThinkingBudget  *int `json:"thinkingBudget,omitempty"`
	// TODO Conflict with thinkingbudget.
	ThinkingLevel string `json:"thinkingLevel,omitempty"`
}

func (*GeminiThinkingConfig) SetThinkingBudget

func (c *GeminiThinkingConfig) SetThinkingBudget(budget int)

func (*GeminiThinkingConfig) UnmarshalJSON

func (c *GeminiThinkingConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON allows GeminiThinkingConfig to accept both snake_case and camelCase fields.

type GeminiUsageMetadata

type GeminiUsageMetadata struct {
	PromptTokenCount        int                         `json:"promptTokenCount"`
	CandidatesTokenCount    int                         `json:"candidatesTokenCount"`
	TotalTokenCount         int                         `json:"totalTokenCount"`
	ThoughtsTokenCount      int                         `json:"thoughtsTokenCount"`
	CachedContentTokenCount int                         `json:"cachedContentTokenCount"`
	PromptTokensDetails     []GeminiPromptTokensDetails `json:"promptTokensDetails"`
}

type GeneralErrorResponse

type GeneralErrorResponse struct {
	Error    json.RawMessage `json:"error"`
	Message  string          `json:"message"`
	Msg      string          `json:"msg"`
	Err      string          `json:"err"`
	ErrorMsg string          `json:"error_msg"`
	Metadata json.RawMessage `json:"metadata,omitempty"`
	Detail   string          `json:"detail,omitempty"`
	Header   struct {
		Message string `json:"message"`
	} `json:"header"`
	Response struct {
		Error struct {
			Message string `json:"message"`
		} `json:"error"`
	} `json:"response"`
}

func (GeneralErrorResponse) ToMessage

func (e GeneralErrorResponse) ToMessage() string

func (GeneralErrorResponse) TryToOpenAIError

func (e GeneralErrorResponse) TryToOpenAIError() *types.OpenAIError

type GeneralOpenAIRequest

type GeneralOpenAIRequest struct {
	Model               string            `json:"model,omitempty"`
	Messages            []Message         `json:"messages,omitempty"`
	Prompt              any               `json:"prompt,omitempty"`
	Prefix              any               `json:"prefix,omitempty"`
	Suffix              any               `json:"suffix,omitempty"`
	Stream              bool              `json:"stream,omitempty"`
	StreamOptions       *StreamOptions    `json:"stream_options,omitempty"`
	MaxTokens           uint              `json:"max_tokens,omitempty"`
	MaxCompletionTokens uint              `json:"max_completion_tokens,omitempty"`
	ReasoningEffort     string            `json:"reasoning_effort,omitempty"`
	Verbosity           json.RawMessage   `json:"verbosity,omitempty"` // gpt-5
	Temperature         *float64          `json:"temperature,omitempty"`
	TopP                float64           `json:"top_p,omitempty"`
	TopK                int               `json:"top_k,omitempty"`
	Stop                any               `json:"stop,omitempty"`
	N                   int               `json:"n,omitempty"`
	Input               any               `json:"input,omitempty"`
	Instruction         string            `json:"instruction,omitempty"`
	Size                string            `json:"size,omitempty"`
	Functions           json.RawMessage   `json:"functions,omitempty"`
	FrequencyPenalty    float64           `json:"frequency_penalty,omitempty"`
	PresencePenalty     float64           `json:"presence_penalty,omitempty"`
	ResponseFormat      *ResponseFormat   `json:"response_format,omitempty"`
	EncodingFormat      json.RawMessage   `json:"encoding_format,omitempty"`
	Seed                float64           `json:"seed,omitempty"`
	ParallelTooCalls    *bool             `json:"parallel_tool_calls,omitempty"`
	Tools               []ToolCallRequest `json:"tools,omitempty"`
	ToolChoice          any               `json:"tool_choice,omitempty"`
	User                string            `json:"user,omitempty"`
	LogProbs            bool              `json:"logprobs,omitempty"`
	TopLogProbs         int               `json:"top_logprobs,omitempty"`
	Dimensions          int               `json:"dimensions,omitempty"`
	Modalities          json.RawMessage   `json:"modalities,omitempty"`
	Audio               json.RawMessage   `json:"audio,omitempty"`
	// 安全标识符,用于帮助 OpenAI 检测可能违反使用政策的应用程序用户
	// 注意:此字段会向 OpenAI 发送用户标识信息,默认过滤以保护用户隐私
	SafetyIdentifier string `json:"safety_identifier,omitempty"`
	// Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
	// 是否存储此次请求数据供 OpenAI 用于评估和优化产品
	// 注意:默认过滤此字段以保护用户隐私,但过滤后可能导致 Codex 无法正常使用
	Store json.RawMessage `json:"store,omitempty"`
	// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field
	PromptCacheKey       string          `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
	LogitBias            json.RawMessage `json:"logit_bias,omitempty"`
	Metadata             json.RawMessage `json:"metadata,omitempty"`
	Prediction           json.RawMessage `json:"prediction,omitempty"`
	// gemini
	ExtraBody json.RawMessage `json:"extra_body,omitempty"`
	//xai
	SearchParameters json.RawMessage `json:"search_parameters,omitempty"`
	// claude
	WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
	// OpenRouter Params
	Usage     json.RawMessage `json:"usage,omitempty"`
	Reasoning json.RawMessage `json:"reasoning,omitempty"`
	// Ali Qwen Params
	VlHighResolutionImages json.RawMessage `json:"vl_high_resolution_images,omitempty"`
	EnableThinking         json.RawMessage `json:"enable_thinking,omitempty"`
	ChatTemplateKwargs     json.RawMessage `json:"chat_template_kwargs,omitempty"`
	EnableSearch           json.RawMessage `json:"enable_search,omitempty"`
	// ollama Params
	Think json.RawMessage `json:"think,omitempty"`
	// baidu v2
	WebSearch json.RawMessage `json:"web_search,omitempty"`
	// doubao,zhipu_v4
	THINKING json.RawMessage `json:"thinking,omitempty"`
	// pplx Params
	SearchDomainFilter     json.RawMessage `json:"search_domain_filter,omitempty"`
	SearchRecencyFilter    string          `json:"search_recency_filter,omitempty"`
	ReturnImages           bool            `json:"return_images,omitempty"`
	ReturnRelatedQuestions bool            `json:"return_related_questions,omitempty"`
	SearchMode             string          `json:"search_mode,omitempty"`
}

GeneralOpenAIRequest represents a general request structure for OpenAI-compatible APIs. 参数增加规范:无引用的参数必须使用json.RawMessage类型,并添加omitempty标签

func (*GeneralOpenAIRequest) GetMaxTokens

func (r *GeneralOpenAIRequest) GetMaxTokens() uint

func (*GeneralOpenAIRequest) GetSystemRoleName

func (r *GeneralOpenAIRequest) GetSystemRoleName() string

func (*GeneralOpenAIRequest) GetTokenCountMeta

func (r *GeneralOpenAIRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*GeneralOpenAIRequest) IsStream

func (r *GeneralOpenAIRequest) IsStream(c *gin.Context) bool

func (*GeneralOpenAIRequest) ParseInput

func (r *GeneralOpenAIRequest) ParseInput() []string

func (*GeneralOpenAIRequest) SetModelName

func (r *GeneralOpenAIRequest) SetModelName(modelName string)

func (*GeneralOpenAIRequest) ToMap

func (r *GeneralOpenAIRequest) ToMap() map[string]any

type GoAPIFetchResponseData

type GoAPIFetchResponseData struct {
	TaskID string              `json:"task_id"`
	Status string              `json:"status"`
	Input  string              `json:"input"`
	Clips  map[string]SunoSong `json:"clips"`
}

type GoAPITaskResponse

type GoAPITaskResponse[T any] struct {
	Code         int    `json:"code"`
	Message      string `json:"message"`
	Data         T      `json:"data"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type GoAPITaskResponseData

type GoAPITaskResponseData struct {
	TaskID string `json:"task_id"`
}

type ImageData

type ImageData struct {
	Url           string `json:"url"`
	B64Json       string `json:"b64_json"`
	RevisedPrompt string `json:"revised_prompt"`
}

type ImageRequest

type ImageRequest struct {
	Model             string          `json:"model"`
	Prompt            string          `json:"prompt" binding:"required"`
	N                 uint            `json:"n,omitempty"`
	Size              string          `json:"size,omitempty"`
	Quality           string          `json:"quality,omitempty"`
	ResponseFormat    string          `json:"response_format,omitempty"`
	Style             json.RawMessage `json:"style,omitempty"`
	User              json.RawMessage `json:"user,omitempty"`
	ExtraFields       json.RawMessage `json:"extra_fields,omitempty"`
	Background        json.RawMessage `json:"background,omitempty"`
	Moderation        json.RawMessage `json:"moderation,omitempty"`
	OutputFormat      json.RawMessage `json:"output_format,omitempty"`
	OutputCompression json.RawMessage `json:"output_compression,omitempty"`
	PartialImages     json.RawMessage `json:"partial_images,omitempty"`
	// Stream            bool            `json:"stream,omitempty"`
	Watermark *bool `json:"watermark,omitempty"`
	// zhipu 4v
	WatermarkEnabled json.RawMessage `json:"watermark_enabled,omitempty"`
	UserId           json.RawMessage `json:"user_id,omitempty"`
	Image            json.RawMessage `json:"image,omitempty"`
	// 用匿名参数接收额外参数
	Extra map[string]json.RawMessage `json:"-"`
}

func (*ImageRequest) GetTokenCountMeta

func (i *ImageRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*ImageRequest) IsStream

func (i *ImageRequest) IsStream(c *gin.Context) bool

func (ImageRequest) MarshalJSON

func (r ImageRequest) MarshalJSON() ([]byte, error)

序列化时需要重新把字段平铺

func (*ImageRequest) SetModelName

func (i *ImageRequest) SetModelName(modelName string)

func (*ImageRequest) UnmarshalJSON

func (i *ImageRequest) UnmarshalJSON(data []byte) error

type ImageResponse

type ImageResponse struct {
	Data     []ImageData     `json:"data"`
	Created  int64           `json:"created"`
	Metadata json.RawMessage `json:"metadata,omitempty"`
}

type ImgUrls

type ImgUrls struct {
	Url string `json:"url"`
}

type IncompleteDetails

type IncompleteDetails struct {
	Reasoning string `json:"reasoning"`
}

type Input

type Input struct {
	Type    string          `json:"type,omitempty"`
	Role    string          `json:"role,omitempty"`
	Content json.RawMessage `json:"content,omitempty"`
}

type InputAudioTranscription

type InputAudioTranscription struct {
	Model string `json:"model"`
}

type InputSchema

type InputSchema struct {
	Type       string `json:"type"`
	Properties any    `json:"properties,omitempty"`
	Required   any    `json:"required,omitempty"`
}

type InputTokenDetails

type InputTokenDetails struct {
	CachedTokens         int `json:"cached_tokens"`
	CachedCreationTokens int `json:"-"`
	TextTokens           int `json:"text_tokens"`
	AudioTokens          int `json:"audio_tokens"`
	ImageTokens          int `json:"image_tokens"`
}

type IntValue

type IntValue int

func (IntValue) MarshalJSON

func (i IntValue) MarshalJSON() ([]byte, error)

func (*IntValue) UnmarshalJSON

func (i *IntValue) UnmarshalJSON(b []byte) error

type LatLng

type LatLng struct {
	Latitude  *float64 `json:"latitude,omitempty"`
	Longitude *float64 `json:"longitude,omitempty"`
}

type MediaContent

type MediaContent struct {
	Type       string `json:"type"`
	Text       string `json:"text,omitempty"`
	ImageUrl   any    `json:"image_url,omitempty"`
	InputAudio any    `json:"input_audio,omitempty"`
	File       any    `json:"file,omitempty"`
	VideoUrl   any    `json:"video_url,omitempty"`
	// OpenRouter Params
	CacheControl json.RawMessage `json:"cache_control,omitempty"`
}

func (*MediaContent) GetFile

func (m *MediaContent) GetFile() *MessageFile

func (*MediaContent) GetImageMedia

func (m *MediaContent) GetImageMedia() *MessageImageUrl

func (*MediaContent) GetInputAudio

func (m *MediaContent) GetInputAudio() *MessageInputAudio

func (*MediaContent) GetVideoUrl

func (m *MediaContent) GetVideoUrl() *MessageVideoUrl

type MediaInput

type MediaInput struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	FileUrl  string `json:"file_url,omitempty"`
	ImageUrl string `json:"image_url,omitempty"`
	Detail   string `json:"detail,omitempty"` // 仅 input_image 有效
}

type MediaResolution

type MediaResolution string

type Message

type Message struct {
	Role             string          `json:"role"`
	Content          any             `json:"content"`
	Name             *string         `json:"name,omitempty"`
	Prefix           *bool           `json:"prefix,omitempty"`
	ReasoningContent string          `json:"reasoning_content,omitempty"`
	Reasoning        string          `json:"reasoning,omitempty"`
	ToolCalls        json.RawMessage `json:"tool_calls,omitempty"`
	ToolCallId       string          `json:"tool_call_id,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) GetPrefix

func (m *Message) GetPrefix() bool

func (*Message) IsStringContent

func (m *Message) IsStringContent() bool

func (*Message) ParseContent

func (m *Message) ParseContent() []MediaContent

func (*Message) ParseToolCalls

func (m *Message) ParseToolCalls() []ToolCallRequest

func (*Message) SetMediaContent

func (m *Message) SetMediaContent(content []MediaContent)

func (*Message) SetNullContent

func (m *Message) SetNullContent()

func (*Message) SetPrefix

func (m *Message) SetPrefix(prefix bool)

func (*Message) SetStringContent

func (m *Message) SetStringContent(content string)

func (*Message) SetToolCalls

func (m *Message) SetToolCalls(toolCalls any)

func (*Message) StringContent

func (m *Message) StringContent() string

type MessageFile

type MessageFile struct {
	FileName string `json:"filename,omitempty"`
	FileData string `json:"file_data,omitempty"`
	FileId   string `json:"file_id,omitempty"`
}

type MessageImageUrl

type MessageImageUrl struct {
	Url      string `json:"url"`
	Detail   string `json:"detail"`
	MimeType string
}

func (*MessageImageUrl) IsRemoteImage

func (m *MessageImageUrl) IsRemoteImage() bool

type MessageInputAudio

type MessageInputAudio struct {
	Data   string `json:"data"` //base64
	Format string `json:"format"`
}

type MessageVideoUrl

type MessageVideoUrl struct {
	Url string `json:"url"`
}

type MidjourneyDto

type MidjourneyDto struct {
	MjId        string      `json:"id"`
	Action      string      `json:"action"`
	CustomId    string      `json:"customId"`
	BotType     string      `json:"botType"`
	Prompt      string      `json:"prompt"`
	PromptEn    string      `json:"promptEn"`
	Description string      `json:"description"`
	State       string      `json:"state"`
	SubmitTime  int64       `json:"submitTime"`
	StartTime   int64       `json:"startTime"`
	FinishTime  int64       `json:"finishTime"`
	ImageUrl    string      `json:"imageUrl"`
	VideoUrl    string      `json:"videoUrl"`
	VideoUrls   []ImgUrls   `json:"videoUrls"`
	Status      string      `json:"status"`
	Progress    string      `json:"progress"`
	FailReason  string      `json:"failReason"`
	Buttons     any         `json:"buttons"`
	MaskBase64  string      `json:"maskBase64"`
	Properties  *Properties `json:"properties"`
}

type MidjourneyRequest

type MidjourneyRequest struct {
	Prompt      string   `json:"prompt"`
	CustomId    string   `json:"customId"`
	BotType     string   `json:"botType"`
	NotifyHook  string   `json:"notifyHook"`
	Action      string   `json:"action"`
	Index       int      `json:"index"`
	State       string   `json:"state"`
	TaskId      string   `json:"taskId"`
	Base64Array []string `json:"base64Array"`
	Content     string   `json:"content"`
	MaskBase64  string   `json:"maskBase64"`
}

type MidjourneyResponse

type MidjourneyResponse struct {
	Code        int         `json:"code"`
	Description string      `json:"description"`
	Properties  interface{} `json:"properties"`
	Result      string      `json:"result"`
}

type MidjourneyResponseWithStatusCode

type MidjourneyResponseWithStatusCode struct {
	StatusCode int `json:"statusCode"`
	Response   MidjourneyResponse
}

type MidjourneyStatus

type MidjourneyStatus struct {
	Status int `json:"status"`
}

type MidjourneyUploadResponse

type MidjourneyUploadResponse struct {
	Code        int      `json:"code"`
	Description string   `json:"description"`
	Result      []string `json:"result"`
}

type MidjourneyWithoutStatus

type MidjourneyWithoutStatus struct {
	Id          int    `json:"id"`
	Code        int    `json:"code"`
	UserId      int    `json:"user_id" gorm:"index"`
	Action      string `json:"action"`
	MjId        string `json:"mj_id" gorm:"index"`
	Prompt      string `json:"prompt"`
	PromptEn    string `json:"prompt_en"`
	Description string `json:"description"`
	State       string `json:"state"`
	SubmitTime  int64  `json:"submit_time"`
	StartTime   int64  `json:"start_time"`
	FinishTime  int64  `json:"finish_time"`
	ImageUrl    string `json:"image_url"`
	Progress    string `json:"progress"`
	FailReason  string `json:"fail_reason"`
	ChannelId   int    `json:"channel_id"`
}

type Notify

type Notify struct {
	Type    string        `json:"type"`
	Title   string        `json:"title"`
	Content string        `json:"content"`
	Values  []interface{} `json:"values"`
}

func NewNotify

func NewNotify(t string, title string, content string, values []interface{}) Notify

type OpenAIEmbeddingResponse

type OpenAIEmbeddingResponse struct {
	Object string                        `json:"object"`
	Data   []OpenAIEmbeddingResponseItem `json:"data"`
	Model  string                        `json:"model"`
	Usage  `json:"usage"`
}

type OpenAIEmbeddingResponseItem

type OpenAIEmbeddingResponseItem struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float64 `json:"embedding"`
}

type OpenAIErrorWithStatusCode

type OpenAIErrorWithStatusCode struct {
	Error      types.OpenAIError `json:"error"`
	StatusCode int               `json:"status_code"`
	LocalError bool
}

type OpenAIModels

type OpenAIModels struct {
	Id                     string                  `json:"id"`
	Object                 string                  `json:"object"`
	Created                int                     `json:"created"`
	OwnedBy                string                  `json:"owned_by"`
	SupportedEndpointTypes []constant.EndpointType `json:"supported_endpoint_types"`
}

这里不好动就不动了,本来想独立出来的(

type OpenAIResponsesCompactionRequest

type OpenAIResponsesCompactionRequest struct {
	Model              string          `json:"model"`
	Input              json.RawMessage `json:"input,omitempty"`
	Instructions       json.RawMessage `json:"instructions,omitempty"`
	PreviousResponseID string          `json:"previous_response_id,omitempty"`
}

func (*OpenAIResponsesCompactionRequest) GetTokenCountMeta

func (r *OpenAIResponsesCompactionRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*OpenAIResponsesCompactionRequest) IsStream

func (*OpenAIResponsesCompactionRequest) SetModelName

func (r *OpenAIResponsesCompactionRequest) SetModelName(modelName string)

type OpenAIResponsesCompactionResponse

type OpenAIResponsesCompactionResponse struct {
	ID        string          `json:"id"`
	Object    string          `json:"object"`
	CreatedAt int             `json:"created_at"`
	Output    json.RawMessage `json:"output"`
	Usage     *Usage          `json:"usage"`
	Error     any             `json:"error,omitempty"`
}

func (*OpenAIResponsesCompactionResponse) GetOpenAIError

type OpenAIResponsesRequest

type OpenAIResponsesRequest struct {
	Model              string          `json:"model"`
	Input              json.RawMessage `json:"input,omitempty"`
	Include            json.RawMessage `json:"include,omitempty"`
	Instructions       json.RawMessage `json:"instructions,omitempty"`
	MaxOutputTokens    uint            `json:"max_output_tokens,omitempty"`
	Metadata           json.RawMessage `json:"metadata,omitempty"`
	ParallelToolCalls  json.RawMessage `json:"parallel_tool_calls,omitempty"`
	PreviousResponseID string          `json:"previous_response_id,omitempty"`
	Reasoning          *Reasoning      `json:"reasoning,omitempty"`
	// 服务层级字段,用于指定 API 服务等级。允许透传可能导致实际计费高于预期,默认应过滤
	ServiceTier          string          `json:"service_tier,omitempty"`
	Store                json.RawMessage `json:"store,omitempty"`
	PromptCacheKey       json.RawMessage `json:"prompt_cache_key,omitempty"`
	PromptCacheRetention json.RawMessage `json:"prompt_cache_retention,omitempty"`
	Stream               bool            `json:"stream,omitempty"`
	Temperature          *float64        `json:"temperature,omitempty"`
	Text                 json.RawMessage `json:"text,omitempty"`
	ToolChoice           json.RawMessage `json:"tool_choice,omitempty"`
	Tools                json.RawMessage `json:"tools,omitempty"` // 需要处理的参数很少,MCP 参数太多不确定,所以用 map
	TopP                 *float64        `json:"top_p,omitempty"`
	Truncation           string          `json:"truncation,omitempty"`
	User                 string          `json:"user,omitempty"`
	MaxToolCalls         uint            `json:"max_tool_calls,omitempty"`
	Prompt               json.RawMessage `json:"prompt,omitempty"`
	// qwen
	EnableThinking json.RawMessage `json:"enable_thinking,omitempty"`
	// perplexity
	Preset json.RawMessage `json:"preset,omitempty"`
}

https://platform.openai.com/docs/api-reference/responses/create

func (*OpenAIResponsesRequest) GetTokenCountMeta

func (r *OpenAIResponsesRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*OpenAIResponsesRequest) GetToolsMap

func (r *OpenAIResponsesRequest) GetToolsMap() []map[string]any

func (*OpenAIResponsesRequest) IsStream

func (r *OpenAIResponsesRequest) IsStream(c *gin.Context) bool

func (*OpenAIResponsesRequest) ParseInput

func (r *OpenAIResponsesRequest) ParseInput() []MediaInput

ParseInput parses the Responses API `input` field into a normalized slice of MediaInput. Reference implementation mirrors Message.ParseContent:

  • input can be a string, treated as an input_text item
  • input can be an array of objects with a `type` field supported types: input_text, input_image, input_file

func (*OpenAIResponsesRequest) SetModelName

func (r *OpenAIResponsesRequest) SetModelName(modelName string)

type OpenAIResponsesResponse

type OpenAIResponsesResponse struct {
	ID                 string             `json:"id"`
	Object             string             `json:"object"`
	CreatedAt          int                `json:"created_at"`
	Status             string             `json:"status"`
	Error              any                `json:"error,omitempty"`
	IncompleteDetails  *IncompleteDetails `json:"incomplete_details,omitempty"`
	Instructions       string             `json:"instructions"`
	MaxOutputTokens    int                `json:"max_output_tokens"`
	Model              string             `json:"model"`
	Output             []ResponsesOutput  `json:"output"`
	ParallelToolCalls  bool               `json:"parallel_tool_calls"`
	PreviousResponseID string             `json:"previous_response_id"`
	Reasoning          *Reasoning         `json:"reasoning"`
	Store              bool               `json:"store"`
	Temperature        float64            `json:"temperature"`
	ToolChoice         string             `json:"tool_choice"`
	Tools              []map[string]any   `json:"tools"`
	TopP               float64            `json:"top_p"`
	Truncation         string             `json:"truncation"`
	Usage              *Usage             `json:"usage"`
	User               json.RawMessage    `json:"user"`
	Metadata           json.RawMessage    `json:"metadata"`
}

func (*OpenAIResponsesResponse) GetOpenAIError

func (o *OpenAIResponsesResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

func (*OpenAIResponsesResponse) GetQuality

func (o *OpenAIResponsesResponse) GetQuality() string

func (*OpenAIResponsesResponse) GetSize

func (o *OpenAIResponsesResponse) GetSize() string

func (*OpenAIResponsesResponse) HasImageGenerationCall

func (o *OpenAIResponsesResponse) HasImageGenerationCall() bool

type OpenAITextResponse

type OpenAITextResponse struct {
	Id      string                     `json:"id"`
	Model   string                     `json:"model"`
	Object  string                     `json:"object"`
	Created any                        `json:"created"`
	Choices []OpenAITextResponseChoice `json:"choices"`
	Error   any                        `json:"error,omitempty"`
	Usage   `json:"usage"`
}

func (*OpenAITextResponse) GetOpenAIError

func (o *OpenAITextResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

type OpenAITextResponseChoice

type OpenAITextResponseChoice struct {
	Index        int `json:"index"`
	Message      `json:"message"`
	FinishReason string `json:"finish_reason"`
}

type OpenAIVideo

type OpenAIVideo struct {
	ID                 string            `json:"id"`
	TaskID             string            `json:"task_id,omitempty"` //兼容旧接口 待废弃
	Object             string            `json:"object"`
	Model              string            `json:"model"`
	Status             string            `json:"status"` // Should use VideoStatus constants: VideoStatusQueued, VideoStatusInProgress, VideoStatusCompleted, VideoStatusFailed
	Progress           int               `json:"progress"`
	CreatedAt          int64             `json:"created_at"`
	CompletedAt        int64             `json:"completed_at,omitempty"`
	ExpiresAt          int64             `json:"expires_at,omitempty"`
	Seconds            string            `json:"seconds,omitempty"`
	Size               string            `json:"size,omitempty"`
	RemixedFromVideoID string            `json:"remixed_from_video_id,omitempty"`
	Error              *OpenAIVideoError `json:"error,omitempty"`
	Metadata           map[string]any    `json:"metadata,omitempty"`
}

func NewOpenAIVideo

func NewOpenAIVideo() *OpenAIVideo

func (*OpenAIVideo) SetMetadata

func (m *OpenAIVideo) SetMetadata(k string, v any)

func (*OpenAIVideo) SetProgressStr

func (m *OpenAIVideo) SetProgressStr(progress string)

type OpenAIVideoError

type OpenAIVideoError struct {
	Message string `json:"message"`
	Code    string `json:"code"`
}

type OpenAIVideoResponse

type OpenAIVideoResponse struct {
	Id        string `json:"id" example:"file-abc123"`
	Object    string `json:"object" example:"file"`
	Bytes     int64  `json:"bytes" example:"120000"`
	CreatedAt int64  `json:"created_at" example:"1677610602"`
	ExpiresAt int64  `json:"expires_at" example:"1677614202"`
	Filename  string `json:"filename" example:"mydata.jsonl"`
	Purpose   string `json:"purpose" example:"fine-tune"`
}

type OutputTokenDetails

type OutputTokenDetails struct {
	TextTokens      int `json:"text_tokens"`
	AudioTokens     int `json:"audio_tokens"`
	ReasoningTokens int `json:"reasoning_tokens"`
}

type PlayGroundRequest

type PlayGroundRequest struct {
	Model string `json:"model,omitempty"`
	Group string `json:"group,omitempty"`
}

type Properties

type Properties struct {
	FinalPrompt   string `json:"finalPrompt"`
	FinalZhPrompt string `json:"finalZhPrompt"`
}

type RealTimeTool

type RealTimeTool struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

type RealtimeContent

type RealtimeContent struct {
	Type       string `json:"type"`
	Text       string `json:"text,omitempty"`
	Audio      string `json:"audio,omitempty"` // Base64-encoded audio bytes.
	Transcript string `json:"transcript,omitempty"`
}

type RealtimeEvent

type RealtimeEvent struct {
	EventId string `json:"event_id"`
	Type    string `json:"type"`
	//PreviousItemId string `json:"previous_item_id"`
	Session  *RealtimeSession   `json:"session,omitempty"`
	Item     *RealtimeItem      `json:"item,omitempty"`
	Error    *types.OpenAIError `json:"error,omitempty"`
	Response *RealtimeResponse  `json:"response,omitempty"`
	Delta    string             `json:"delta,omitempty"`
	Audio    string             `json:"audio,omitempty"`
}

type RealtimeItem

type RealtimeItem struct {
	Id        string            `json:"id"`
	Type      string            `json:"type"`
	Status    string            `json:"status"`
	Role      string            `json:"role"`
	Content   []RealtimeContent `json:"content"`
	Name      *string           `json:"name,omitempty"`
	ToolCalls any               `json:"tool_calls,omitempty"`
	CallId    string            `json:"call_id,omitempty"`
}

type RealtimeResponse

type RealtimeResponse struct {
	Usage *RealtimeUsage `json:"usage"`
}

type RealtimeSession

type RealtimeSession struct {
	Modalities              []string                `json:"modalities"`
	Instructions            string                  `json:"instructions"`
	Voice                   string                  `json:"voice"`
	InputAudioFormat        string                  `json:"input_audio_format"`
	OutputAudioFormat       string                  `json:"output_audio_format"`
	InputAudioTranscription InputAudioTranscription `json:"input_audio_transcription"`
	TurnDetection           interface{}             `json:"turn_detection"`
	Tools                   []RealTimeTool          `json:"tools"`
	ToolChoice              string                  `json:"tool_choice"`
	Temperature             float64                 `json:"temperature"`
}

type RealtimeUsage

type RealtimeUsage struct {
	TotalTokens        int                `json:"total_tokens"`
	InputTokens        int                `json:"input_tokens"`
	OutputTokens       int                `json:"output_tokens"`
	InputTokenDetails  InputTokenDetails  `json:"input_token_details"`
	OutputTokenDetails OutputTokenDetails `json:"output_token_details"`
}

type Reasoning

type Reasoning struct {
	Effort  string `json:"effort,omitempty"`
	Summary string `json:"summary,omitempty"`
}

type Request

type Request interface {
	GetTokenCountMeta() *types.TokenCountMeta
	IsStream(c *gin.Context) bool
	SetModelName(modelName string)
}

type RerankDocument

type RerankDocument struct {
	Text any `json:"text"`
}

type RerankRequest

type RerankRequest struct {
	Documents       []any  `json:"documents"`
	Query           string `json:"query"`
	Model           string `json:"model"`
	TopN            int    `json:"top_n,omitempty"`
	ReturnDocuments *bool  `json:"return_documents,omitempty"`
	MaxChunkPerDoc  int    `json:"max_chunk_per_doc,omitempty"`
	OverLapTokens   int    `json:"overlap_tokens,omitempty"`
}

func (*RerankRequest) GetReturnDocuments

func (r *RerankRequest) GetReturnDocuments() bool

func (*RerankRequest) GetTokenCountMeta

func (r *RerankRequest) GetTokenCountMeta() *types.TokenCountMeta

func (*RerankRequest) IsStream

func (r *RerankRequest) IsStream(c *gin.Context) bool

func (*RerankRequest) SetModelName

func (r *RerankRequest) SetModelName(modelName string)

type RerankResponse

type RerankResponse struct {
	Results []RerankResponseResult `json:"results"`
	Usage   Usage                  `json:"usage"`
}

type RerankResponseResult

type RerankResponseResult struct {
	Document       any     `json:"document,omitempty"`
	Index          int     `json:"index"`
	RelevanceScore float64 `json:"relevance_score"`
}

type ResponseFormat

type ResponseFormat struct {
	Type       string          `json:"type,omitempty"`
	JsonSchema json.RawMessage `json:"json_schema,omitempty"`
}

type ResponsesOutput

type ResponsesOutput struct {
	Type      string                   `json:"type"`
	ID        string                   `json:"id"`
	Status    string                   `json:"status"`
	Role      string                   `json:"role"`
	Content   []ResponsesOutputContent `json:"content"`
	Quality   string                   `json:"quality"`
	Size      string                   `json:"size"`
	CallId    string                   `json:"call_id,omitempty"`
	Name      string                   `json:"name,omitempty"`
	Arguments string                   `json:"arguments,omitempty"`
}

type ResponsesOutputContent

type ResponsesOutputContent struct {
	Type        string        `json:"type"`
	Text        string        `json:"text"`
	Annotations []interface{} `json:"annotations"`
}

type ResponsesReasoningSummaryPart added in v0.10.8

type ResponsesReasoningSummaryPart struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type ResponsesStreamResponse

type ResponsesStreamResponse struct {
	Type     string                   `json:"type"`
	Response *OpenAIResponsesResponse `json:"response,omitempty"`
	Delta    string                   `json:"delta,omitempty"`
	Item     *ResponsesOutput         `json:"item,omitempty"`
	// - response.function_call_arguments.delta
	// - response.function_call_arguments.done
	OutputIndex  *int                           `json:"output_index,omitempty"`
	ContentIndex *int                           `json:"content_index,omitempty"`
	SummaryIndex *int                           `json:"summary_index,omitempty"`
	ItemID       string                         `json:"item_id,omitempty"`
	Part         *ResponsesReasoningSummaryPart `json:"part,omitempty"`
}

ResponsesStreamResponse 用于处理 /v1/responses 流式响应

type RetrievalConfig

type RetrievalConfig struct {
	LatLng       *LatLng `json:"latLng,omitempty"`
	LanguageCode string  `json:"languageCode,omitempty"`
}

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"`
}

type SensitiveResponse

type SensitiveResponse struct {
	SensitiveWords []string `json:"sensitive_words"`
	Content        string   `json:"content"`
}

type SimpleResponse

type SimpleResponse struct {
	Usage `json:"usage"`
	Error any `json:"error"`
}

func (*SimpleResponse) GetOpenAIError

func (s *SimpleResponse) GetOpenAIError() *types.OpenAIError

GetOpenAIError 从动态错误类型中提取OpenAIError结构

type StreamOptions

type StreamOptions struct {
	IncludeUsage bool `json:"include_usage,omitempty"`
}

type SunoDataResponse

type SunoDataResponse struct {
	TaskID     string          `json:"task_id" gorm:"type:varchar(50);index"`
	Action     string          `json:"action" gorm:"type:varchar(40);index"` // 任务类型, song, lyrics, description-mode
	Status     string          `json:"status" gorm:"type:varchar(20);index"` // 任务状态, submitted, queueing, processing, success, failed
	FailReason string          `json:"fail_reason"`
	SubmitTime int64           `json:"submit_time" gorm:"index"`
	StartTime  int64           `json:"start_time" gorm:"index"`
	FinishTime int64           `json:"finish_time" gorm:"index"`
	Data       json.RawMessage `json:"data" gorm:"type:json"`
}

type SunoGoAPISubmitReq

type SunoGoAPISubmitReq struct {
	CustomMode bool `json:"custom_mode"`

	Input SunoGoAPISubmitReqInput `json:"input"`

	NotifyHook string `json:"notify_hook,omitempty"`
}

type SunoGoAPISubmitReqInput

type SunoGoAPISubmitReqInput struct {
	GptDescriptionPrompt string  `json:"gpt_description_prompt"`
	Prompt               string  `json:"prompt"`
	Mv                   string  `json:"mv"`
	Title                string  `json:"title"`
	Tags                 string  `json:"tags"`
	ContinueAt           float64 `json:"continue_at"`
	TaskID               string  `json:"task_id"`
	ContinueClipId       string  `json:"continue_clip_id"`
	MakeInstrumental     bool    `json:"make_instrumental"`
}

type SunoLyrics

type SunoLyrics struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Title  string `json:"title"`
	Text   string `json:"text"`
}

type SunoMetadata

type SunoMetadata struct {
	Tags                 string      `json:"tags"`
	Prompt               string      `json:"prompt"`
	GPTDescriptionPrompt interface{} `json:"gpt_description_prompt"`
	AudioPromptID        interface{} `json:"audio_prompt_id"`
	Duration             interface{} `json:"duration"`
	ErrorType            interface{} `json:"error_type"`
	ErrorMessage         interface{} `json:"error_message"`
}

type SunoSong

type SunoSong struct {
	ID                string       `json:"id"`
	VideoURL          string       `json:"video_url"`
	AudioURL          string       `json:"audio_url"`
	ImageURL          string       `json:"image_url"`
	ImageLargeURL     string       `json:"image_large_url"`
	MajorModelVersion string       `json:"major_model_version"`
	ModelName         string       `json:"model_name"`
	Status            string       `json:"status"`
	Title             string       `json:"title"`
	Text              string       `json:"text"`
	Metadata          SunoMetadata `json:"metadata"`
}

type SunoSubmitReq

type SunoSubmitReq struct {
	GptDescriptionPrompt string  `json:"gpt_description_prompt,omitempty"`
	Prompt               string  `json:"prompt,omitempty"`
	Mv                   string  `json:"mv,omitempty"`
	Title                string  `json:"title,omitempty"`
	Tags                 string  `json:"tags,omitempty"`
	ContinueAt           float64 `json:"continue_at,omitempty"`
	TaskID               string  `json:"task_id,omitempty"`
	ContinueClipId       string  `json:"continue_clip_id,omitempty"`
	MakeInstrumental     bool    `json:"make_instrumental"`
}

type SwapFaceRequest

type SwapFaceRequest struct {
	SourceBase64 string `json:"sourceBase64"`
	TargetBase64 string `json:"targetBase64"`
}

type SyncableChannel

type SyncableChannel struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	BaseURL string `json:"base_url"`
	Status  int    `json:"status"`
}

type TaskData

type TaskData interface {
	SunoDataResponse | []SunoDataResponse | string | any
}

type TaskDto

type TaskDto struct {
	TaskID     string          `json:"task_id"` // 第三方id,不一定有/ song id\ Task id
	Action     string          `json:"action"`  // 任务类型, song, lyrics, description-mode
	Status     string          `json:"status"`  // 任务状态, submitted, queueing, processing, success, failed
	FailReason string          `json:"fail_reason"`
	SubmitTime int64           `json:"submit_time"`
	StartTime  int64           `json:"start_time"`
	FinishTime int64           `json:"finish_time"`
	Progress   string          `json:"progress"`
	Data       json.RawMessage `json:"data"`
}

type TaskError

type TaskError struct {
	Code       string `json:"code"`
	Message    string `json:"message"`
	Data       any    `json:"data"`
	StatusCode int    `json:"-"`
	LocalError bool   `json:"-"`
	Error      error  `json:"-"`
}

type TaskResponse

type TaskResponse[T TaskData] struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    T      `json:"data"`
}

func (*TaskResponse[T]) IsSuccess

func (t *TaskResponse[T]) IsSuccess() bool

type TestResult

type TestResult struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

TestResult 上游测试连通性结果

type TextResponse

type TextResponse struct {
	Id      string                     `json:"id"`
	Object  string                     `json:"object"`
	Created int64                      `json:"created"`
	Model   string                     `json:"model"`
	Choices []OpenAITextResponseChoice `json:"choices"`
	Usage   `json:"usage"`
}

type Thinking

type Thinking struct {
	Type         string `json:"type"`
	BudgetTokens *int   `json:"budget_tokens,omitempty"`
}

func (*Thinking) GetBudgetTokens

func (c *Thinking) GetBudgetTokens() int

type Tool

type Tool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	InputSchema map[string]interface{} `json:"input_schema"`
}

type ToolCallRequest

type ToolCallRequest struct {
	ID       string          `json:"id,omitempty"`
	Type     string          `json:"type"`
	Function FunctionRequest `json:"function,omitempty"`
	Custom   json.RawMessage `json:"custom,omitempty"`
}

type ToolCallResponse

type ToolCallResponse struct {
	// Index is not nil only in chat completion chunk object
	Index    *int             `json:"index,omitempty"`
	ID       string           `json:"id,omitempty"`
	Type     any              `json:"type"`
	Function FunctionResponse `json:"function"`
}

func (*ToolCallResponse) SetIndex

func (c *ToolCallResponse) SetIndex(i int)

type ToolConfig

type ToolConfig struct {
	FunctionCallingConfig *FunctionCallingConfig `json:"functionCallingConfig,omitempty"`
	RetrievalConfig       *RetrievalConfig       `json:"retrievalConfig,omitempty"`
}

type UpstreamDTO

type UpstreamDTO struct {
	ID       int    `json:"id,omitempty"`
	Name     string `json:"name" binding:"required"`
	BaseURL  string `json:"base_url" binding:"required"`
	Endpoint string `json:"endpoint"`
}

type UpstreamRequest

type UpstreamRequest struct {
	ChannelIDs []int64       `json:"channel_ids"`
	Upstreams  []UpstreamDTO `json:"upstreams"`
	Timeout    int           `json:"timeout"`
}

type Usage

type Usage struct {
	PromptTokens         int `json:"prompt_tokens"`
	CompletionTokens     int `json:"completion_tokens"`
	TotalTokens          int `json:"total_tokens"`
	PromptCacheHitTokens int `json:"prompt_cache_hit_tokens,omitempty"`

	PromptTokensDetails    InputTokenDetails  `json:"prompt_tokens_details"`
	CompletionTokenDetails OutputTokenDetails `json:"completion_tokens_details"`
	InputTokens            int                `json:"input_tokens"`
	OutputTokens           int                `json:"output_tokens"`
	InputTokensDetails     *InputTokenDetails `json:"input_tokens_details"`

	// claude cache 1h
	ClaudeCacheCreation5mTokens int `json:"claude_cache_creation_5_m_tokens"`
	ClaudeCacheCreation1hTokens int `json:"claude_cache_creation_1_h_tokens"`

	// OpenRouter Params
	Cost any `json:"cost,omitempty"`
}

type UserSetting

type UserSetting struct {
	NotifyType            string  `json:"notify_type,omitempty"`                    // QuotaWarningType 额度预警类型
	QuotaWarningThreshold float64 `json:"quota_warning_threshold,omitempty"`        // QuotaWarningThreshold 额度预警阈值
	WebhookUrl            string  `json:"webhook_url,omitempty"`                    // WebhookUrl webhook地址
	WebhookSecret         string  `json:"webhook_secret,omitempty"`                 // WebhookSecret webhook密钥
	NotificationEmail     string  `json:"notification_email,omitempty"`             // NotificationEmail 通知邮箱地址
	BarkUrl               string  `json:"bark_url,omitempty"`                       // BarkUrl Bark推送URL
	GotifyUrl             string  `json:"gotify_url,omitempty"`                     // GotifyUrl Gotify服务器地址
	GotifyToken           string  `json:"gotify_token,omitempty"`                   // GotifyToken Gotify应用令牌
	GotifyPriority        int     `json:"gotify_priority"`                          // GotifyPriority Gotify消息优先级
	AcceptUnsetRatioModel bool    `json:"accept_unset_model_ratio_model,omitempty"` // AcceptUnsetRatioModel 是否接受未设置价格的模型
	RecordIpLog           bool    `json:"record_ip_log,omitempty"`                  // 是否记录请求和错误日志IP
	SidebarModules        string  `json:"sidebar_modules,omitempty"`                // SidebarModules 左侧边栏模块配置
	BillingPreference     string  `json:"billing_preference,omitempty"`             // BillingPreference 扣费策略(订阅/钱包)
	Language              string  `json:"language,omitempty"`                       // Language 用户语言偏好 (zh, en)
}

type VertexKeyType

type VertexKeyType string
const (
	VertexKeyTypeJSON   VertexKeyType = "json"
	VertexKeyTypeAPIKey VertexKeyType = "api_key"
)

type VideoRequest

type VideoRequest struct {
	Model  string `json:"model,omitempty" example:"kling-v1"`  // Model/style ID
	Prompt string `json:"prompt,omitempty" example:"宇航员站起身走了"` // Text prompt
	Image  string ``                                           // Image input (URL/Base64)
	/* 172-byte string literal not displayed */
	Duration       float64        `json:"duration" example:"5.0"`                  // Video duration (seconds)
	Width          int            `json:"width" example:"512"`                     // Video width
	Height         int            `json:"height" example:"512"`                    // Video height
	Fps            int            `json:"fps,omitempty" example:"30"`              // Video frame rate
	Seed           int            `json:"seed,omitempty" example:"20231234"`       // Random seed
	N              int            `json:"n,omitempty" example:"1"`                 // Number of videos to generate
	ResponseFormat string         `json:"response_format,omitempty" example:"url"` // Response format
	User           string         `json:"user,omitempty" example:"user-1234"`      // User identifier
	Metadata       map[string]any `json:"metadata,omitempty"`                      // Vendor-specific/custom params (e.g. negative_prompt, style, quality_level, etc.)
}

type VideoResponse

type VideoResponse struct {
	TaskId string `json:"task_id"`
	Status string `json:"status"`
}

VideoResponse 视频生成提交任务后的响应

type VideoTaskError

type VideoTaskError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

VideoTaskError 视频任务错误信息

type VideoTaskMetadata

type VideoTaskMetadata struct {
	Duration float64 `json:"duration" example:"5.0"`  // 实际生成的视频时长
	Fps      int     `json:"fps" example:"30"`        // 实际帧率
	Width    int     `json:"width" example:"512"`     // 实际宽度
	Height   int     `json:"height" example:"512"`    // 实际高度
	Seed     int     `json:"seed" example:"20231234"` // 使用的随机种子
}

VideoTaskMetadata 视频任务元数据

type VideoTaskResponse

type VideoTaskResponse struct {
	TaskId   string             `json:"task_id" example:"abcd1234efgh"` // 任务ID
	Status   string             `json:"status" example:"succeeded"`     // 任务状态
	Url      string             `json:"url,omitempty"`                  // 视频资源URL(成功时)
	Format   string             `json:"format,omitempty" example:"mp4"` // 视频格式
	Metadata *VideoTaskMetadata `json:"metadata,omitempty"`             // 结果元数据
	Error    *VideoTaskError    `json:"error,omitempty"`                // 错误信息(失败时)
}

VideoTaskResponse 查询视频生成任务状态的响应

type WebSearchOptions

type WebSearchOptions struct {
	SearchContextSize string          `json:"search_context_size,omitempty"`
	UserLocation      json.RawMessage `json:"user_location,omitempty"`
}

type WhisperVerboseJSONResponse

type WhisperVerboseJSONResponse struct {
	Task     string    `json:"task,omitempty"`
	Language string    `json:"language,omitempty"`
	Duration float64   `json:"duration,omitempty"`
	Text     string    `json:"text,omitempty"`
	Segments []Segment `json:"segments,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL