Documentation
¶
Index ¶
- Variables
- func FormatStreamError(_ context.Context, err error) any
- func JSONError(c *gin.Context, status int, err error)
- func WriteBinaryStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
- func WriteGeminiStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
- func WriteJSONStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
- func WriteSSEStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
- func WriteSSEStreamWithErrorFormatter(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent], ...)
- type APIKeyHandlers
- type APIKeyHandlersParams
- type AdapterDTO
- type AdapterHandlers
- func (handlers *AdapterHandlers) ChatCompletions(c *gin.Context)
- func (handlers *AdapterHandlers) ListModels(c *gin.Context)
- func (handlers *AdapterHandlers) Messages(c *gin.Context)
- func (handlers *AdapterHandlers) Responses(c *gin.Context)
- func (handlers *AdapterHandlers) RetrieveModel(c *gin.Context)
- type AdapterHandlersParams
- type AiSDKHandlers
- type AiSdkHandlersParams
- type AnthropicHandlers
- type AnthropicHandlersParams
- type AnthropicModel
- type AntigravityHandlers
- type AntigravityHandlersParams
- type AuthHandlers
- type AuthHandlersParams
- type BindingDTO
- type BindingInput
- type Capabilities
- type ChatCompletionHandlers
- type ClaudeCodeHandlers
- type ClaudeCodeHandlersParams
- type Clock
- type CodexHandlers
- type CodexHandlersParams
- type CopilotHandlers
- type CopilotHandlersParams
- type DecodeCodexAuthJSONRequest
- type DecodeCodexAuthJSONResponse
- type DoubaoHandlers
- type DoubaoHandlersParams
- type DownloadContentRequest
- type ExchangeAntigravityOAuthRequest
- type ExchangeAntigravityOAuthResponse
- type ExchangeClaudeCodeOAuthRequest
- type ExchangeClaudeCodeOAuthResponse
- type ExchangeCodexOAuthRequest
- type ExchangeCodexOAuthResponse
- type GatewayHandlers
- func (h *GatewayHandlers) DeleteAdapter(c *gin.Context)
- func (h *GatewayHandlers) GetRuntimeStatus(c *gin.Context)
- func (h *GatewayHandlers) ListAdapters(c *gin.Context)
- func (h *GatewayHandlers) RefreshGateway(c *gin.Context)
- func (h *GatewayHandlers) RenameAdapter(c *gin.Context)
- func (h *GatewayHandlers) UpdateAdapter(c *gin.Context)
- type GatewayHandlersParams
- type GeminiHandlers
- type GeminiHandlersParams
- type GeminiModel
- type HealthResponse
- type InitializeSystemRequest
- type InitializeSystemResponse
- type JinaHandlers
- type JinaHandlersParams
- type ListAdaptersResponse
- type Modalities
- type OIDCHandlerParams
- type OIDCHandlers
- func (h *OIDCHandlers) Callback(c *gin.Context)
- func (h *OIDCHandlers) Exchange(c *gin.Context)
- func (h *OIDCHandlers) GetAuthorizeURL(c *gin.Context)
- func (h *OIDCHandlers) GetLinkAuthorizeURL(c *gin.Context)
- func (h *OIDCHandlers) GetProviders(c *gin.Context)
- func (h *OIDCHandlers) RegisterRoutes(r gin.IRouter)
- type OpenAIHandlers
- func (handlers *OpenAIHandlers) ChatCompletion(c *gin.Context)
- func (handlers *OpenAIHandlers) CompactResponse(c *gin.Context)
- func (handlers *OpenAIHandlers) Completion(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateEmbedding(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateImage(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateImageEdit(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateImageVariation(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateResponse(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateSpeech(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateTranscription(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateTranslation(c *gin.Context)
- func (handlers *OpenAIHandlers) CreateVideo(c *gin.Context)
- func (handlers *OpenAIHandlers) DeleteVideo(c *gin.Context)
- func (handlers *OpenAIHandlers) GetVideo(c *gin.Context)
- func (handlers *OpenAIHandlers) ListModels(c *gin.Context)
- func (handlers *OpenAIHandlers) RetrieveModel(c *gin.Context)
- type OpenAIHandlersParams
- type OpenAIModel
- type PlaygroundHandlers
- type PlaygroundHandlersParams
- type PlaygroundResponseError
- type PollCopilotOAuthRequest
- type PollCopilotOAuthResponse
- type Pricing
- type ProtocolDTO
- type ProtocolInput
- type RenameAdapterRequest
- type RequestContentHandlers
- type RequestContentHandlersParams
- type RequestDetailPreviewContract
- type RequestPreviewFallbackResponse
- type RequestPreviewHandlers
- type RequestPreviewHandlersParams
- type SignInRequest
- type SignInResponse
- type StartAntigravityOAuthRequest
- type StartAntigravityOAuthResponse
- type StartClaudeCodeOAuthRequest
- type StartClaudeCodeOAuthResponse
- type StartCodexOAuthRequest
- type StartCodexOAuthResponse
- type StartCopilotOAuthRequest
- type StartCopilotOAuthResponse
- type StreamErrorFormatter
- type StreamWriter
- type SystemHandlers
- type SystemHandlersParams
- type SystemStatusResponse
- type TargetCapabilitiesDTO
- type TargetDTO
- type TargetInput
- type UpdateAdapterRequest
- type WebhookDebugResponse
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Module("api", fx.Provide(NewOpenAIHandlers), fx.Provide(NewAnthropicHandlers), fx.Provide(NewAdapterHandlers), fx.Provide(NewGeminiHandlers), fx.Provide(NewAiSDKHandlers), fx.Provide(NewPlaygroundHandlers), fx.Provide(NewSystemHandlers), fx.Provide(NewAuthHandlers), fx.Provide(NewAPIKeyHandlers), fx.Provide(NewJinaHandlers), fx.Provide(NewDoubaoHandlers), fx.Provide(NewCodexHandlers), fx.Provide(NewClaudeCodeHandlers), fx.Provide(NewAntigravityHandlers), fx.Provide(NewCopilotHandlers), fx.Provide(NewRequestContentHandlers), fx.Provide(NewOIDCHandlers), fx.Provide(NewRequestPreviewHandlers), fx.Provide(NewGatewayHandlers), fx.Invoke(initLogger), )
Functions ¶
func FormatStreamError ¶
FormatStreamError formats a stream error into an OpenAI-compatible JSON error object.
func JSONError ¶
JSONError returns a JSON error response and adds the error to gin context for access logging.
func WriteBinaryStream ¶
func WriteBinaryStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
WriteBinaryStream writes raw bytes from stream events directly to the response body. The first chunk type is treated as the stream Content-Type when present.
func WriteGeminiStream ¶
func WriteGeminiStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
func WriteJSONStream ¶
func WriteJSONStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
WriteJSONStream writes stream events as plain JSON text stream.
func WriteSSEStream ¶
func WriteSSEStream(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
WriteSSEStream writes stream events as Server-Sent Events (SSE) with default error formatting.
func WriteSSEStreamWithErrorFormatter ¶
func WriteSSEStreamWithErrorFormatter(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent], formatErr StreamErrorFormatter)
WriteSSEStreamWithErrorFormatter writes stream events as SSE with a custom error formatter.
Types ¶
type APIKeyHandlers ¶
type APIKeyHandlers struct {
APIKeyService *biz.APIKeyService
}
func NewAPIKeyHandlers ¶
func NewAPIKeyHandlers(params APIKeyHandlersParams) *APIKeyHandlers
type APIKeyHandlersParams ¶
type APIKeyHandlersParams struct {
fx.In
APIKeyService *biz.APIKeyService
}
type AdapterDTO ¶
type AdapterDTO struct {
ID int `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
InboundAPIFormat string `json:"inbound_api_format"`
Status string `json:"status"`
Remark *string `json:"remark,omitempty"`
Bindings []BindingDTO `json:"bindings"`
}
AdapterDTO 适配器数据传输对象.
type AdapterHandlers ¶
type AdapterHandlers struct {
AdapterService *biz.AdapterService
ChatCompletionHandlers *ChatCompletionHandlers
ResponseCompletionHandlers *ChatCompletionHandlers
MessagesHandlers *ChatCompletionHandlers
}
AdapterHandlers 是动态适配器路由的协议门面。 请求解析、编排和流式响应均复用现有协议 handler,仅替换候选选择器。
func NewAdapterHandlers ¶
func NewAdapterHandlers(params AdapterHandlersParams) *AdapterHandlers
func (*AdapterHandlers) ChatCompletions ¶
func (handlers *AdapterHandlers) ChatCompletions(c *gin.Context)
ChatCompletions 处理 Adapter 的 OpenAI Chat Completions 入站协议。
func (*AdapterHandlers) ListModels ¶
func (handlers *AdapterHandlers) ListModels(c *gin.Context)
ListModels 只返回当前 Adapter 绑定的逻辑模型 ID。
func (*AdapterHandlers) Messages ¶
func (handlers *AdapterHandlers) Messages(c *gin.Context)
Messages 处理 Adapter 的 Anthropic Messages 入站协议。
func (*AdapterHandlers) Responses ¶
func (handlers *AdapterHandlers) Responses(c *gin.Context)
Responses 处理 Adapter 的 OpenAI Responses 入站协议。
func (*AdapterHandlers) RetrieveModel ¶
func (handlers *AdapterHandlers) RetrieveModel(c *gin.Context)
RetrieveModel 返回当前 Adapter 的单个逻辑模型。
type AdapterHandlersParams ¶
type AdapterHandlersParams struct {
fx.In
AdapterService *biz.AdapterService
AdapterSelector *orchestrator.AdapterCandidateSelector
OpenAI *OpenAIHandlers
Anthropic *AnthropicHandlers
}
type AiSDKHandlers ¶
type AiSDKHandlers struct {
ChatCompletionHandler *ChatCompletionHandlers
}
func NewAiSDKHandlers ¶
func NewAiSDKHandlers(params AiSdkHandlersParams) *AiSDKHandlers
func (*AiSDKHandlers) ChatCompletion ¶
func (handlers *AiSDKHandlers) ChatCompletion(c *gin.Context)
type AiSdkHandlersParams ¶
type AiSdkHandlersParams struct {
fx.In
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type AnthropicHandlers ¶
type AnthropicHandlers struct {
ChannelService *biz.ChannelService
ModelService *biz.ModelService
SystemService *biz.SystemService
ChatCompletionHandlers *ChatCompletionHandlers
}
func NewAnthropicHandlers ¶
func NewAnthropicHandlers(params AnthropicHandlersParams) *AnthropicHandlers
func (*AnthropicHandlers) CreateMessage ¶
func (handlers *AnthropicHandlers) CreateMessage(c *gin.Context)
func (*AnthropicHandlers) ListModels ¶
func (handlers *AnthropicHandlers) ListModels(c *gin.Context)
ListModels returns all available models. It uses QueryAllChannelModels setting from system config to determine model source.
type AnthropicHandlersParams ¶
type AnthropicHandlersParams struct {
fx.In
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type AnthropicModel ¶
type AntigravityHandlers ¶
type AntigravityHandlers struct {
// contains filtered or unexported fields
}
func NewAntigravityHandlers ¶
func NewAntigravityHandlers(params AntigravityHandlersParams) *AntigravityHandlers
func (*AntigravityHandlers) Exchange ¶
func (h *AntigravityHandlers) Exchange(c *gin.Context)
Exchange exchanges callback URL for OAuth credentials. POST /admin/antigravity/oauth/exchange.
func (*AntigravityHandlers) StartOAuth ¶
func (h *AntigravityHandlers) StartOAuth(c *gin.Context)
StartOAuth creates a PKCE session and returns the authorize URL. POST /admin/antigravity/oauth/start.
type AntigravityHandlersParams ¶
type AntigravityHandlersParams struct {
fx.In
CacheConfig xcache.Config
HttpClient *httpclient.HttpClient
}
type AuthHandlers ¶
type AuthHandlers struct {
AuthService *biz.AuthService
}
func NewAuthHandlers ¶
func NewAuthHandlers(params AuthHandlersParams) *AuthHandlers
func (*AuthHandlers) SignIn ¶
func (h *AuthHandlers) SignIn(c *gin.Context)
SignIn handles user authentication.
type AuthHandlersParams ¶
type AuthHandlersParams struct {
fx.In
AuthService *biz.AuthService
}
type BindingDTO ¶
type BindingDTO struct {
ID int `json:"id"`
SourceModelID string `json:"source_model_id"`
ModelID int `json:"model_id"`
Enabled bool `json:"enabled"`
Remark *string `json:"remark,omitempty"`
}
BindingDTO 适配器绑定数据传输对象.
type BindingInput ¶
type BindingInput struct {
SourceModelID string `json:"source_model_id" binding:"required"`
ModelID int `json:"model_id" binding:"required"`
Enabled bool `json:"enabled"`
Remark string `json:"remark,omitempty"`
}
BindingInput 绑定输入.
type Capabilities ¶
type ChatCompletionHandlers ¶
type ChatCompletionHandlers struct {
ChatCompletionOrchestrator *orchestrator.ChatCompletionOrchestrator
StreamWriter StreamWriter
}
func NewChatCompletionHandlers ¶
func NewChatCompletionHandlers(orchestrator *orchestrator.ChatCompletionOrchestrator) *ChatCompletionHandlers
func (*ChatCompletionHandlers) ChatCompletion ¶
func (handlers *ChatCompletionHandlers) ChatCompletion(c *gin.Context)
func (*ChatCompletionHandlers) ChatCompletionWithRequest ¶
func (handlers *ChatCompletionHandlers) ChatCompletionWithRequest(c *gin.Context, genericReq *httpclient.Request)
func (*ChatCompletionHandlers) WithStreamWriter ¶
func (handlers *ChatCompletionHandlers) WithStreamWriter(writer StreamWriter) *ChatCompletionHandlers
WithStreamWriter returns a new ChatCompletionHandlers with the specified stream writer.
type ClaudeCodeHandlers ¶
type ClaudeCodeHandlers struct {
// contains filtered or unexported fields
}
func NewClaudeCodeHandlers ¶
func NewClaudeCodeHandlers(params ClaudeCodeHandlersParams) *ClaudeCodeHandlers
func (*ClaudeCodeHandlers) Exchange ¶
func (h *ClaudeCodeHandlers) Exchange(c *gin.Context)
Exchange exchanges callback URL for OAuth credentials JSON. POST /admin/claudecode/oauth/exchange.
func (*ClaudeCodeHandlers) StartOAuth ¶
func (h *ClaudeCodeHandlers) StartOAuth(c *gin.Context)
StartOAuth creates a PKCE session and returns the authorize URL. POST /admin/claudecode/oauth/start.
type ClaudeCodeHandlersParams ¶
type ClaudeCodeHandlersParams struct {
fx.In
CacheConfig xcache.Config
HttpClient *httpclient.HttpClient
}
type CodexHandlers ¶
type CodexHandlers struct {
// contains filtered or unexported fields
}
func NewCodexHandlers ¶
func NewCodexHandlers(params CodexHandlersParams) *CodexHandlers
func (*CodexHandlers) DecodeAuthJSON ¶
func (h *CodexHandlers) DecodeAuthJSON(c *gin.Context)
DecodeAuthJSON decodes Codex auth.json into normalized OAuth credentials JSON. POST /admin/codex/auth/decode.
func (*CodexHandlers) Exchange ¶
func (h *CodexHandlers) Exchange(c *gin.Context)
Exchange exchanges callback URL for OAuth credentials JSON. POST /admin/codex/oauth/exchange.
func (*CodexHandlers) StartOAuth ¶
func (h *CodexHandlers) StartOAuth(c *gin.Context)
StartOAuth creates a PKCE session and returns the authorize URL. POST /admin/codex/oauth/start.
type CodexHandlersParams ¶
type CodexHandlersParams struct {
fx.In
CacheConfig xcache.Config
HttpClient *httpclient.HttpClient
}
type CopilotHandlers ¶
type CopilotHandlers struct {
// contains filtered or unexported fields
}
CopilotHandlers provides HTTP handlers for GitHub Copilot OAuth device flow.
func NewCopilotHandlers ¶
func NewCopilotHandlers(params CopilotHandlersParams) *CopilotHandlers
func (*CopilotHandlers) PollOAuth ¶
func (h *CopilotHandlers) PollOAuth(c *gin.Context)
PollOAuth polls for the OAuth access token using the device flow. POST /admin/copilot/oauth/poll
func (*CopilotHandlers) StartOAuth ¶
func (h *CopilotHandlers) StartOAuth(c *gin.Context)
StartOAuth initiates the GitHub OAuth device flow. POST /admin/copilot/oauth/start
type CopilotHandlersParams ¶
type CopilotHandlersParams struct {
fx.In
CacheConfig xcache.Config
HttpClient *httpclient.HttpClient
Clock Clock `optional:"true"`
}
CopilotHandlersParams contains the dependencies for CopilotHandlers.
type DecodeCodexAuthJSONRequest ¶
type DecodeCodexAuthJSONRequest struct {
AuthJSON string `json:"auth_json" binding:"required"`
}
type DecodeCodexAuthJSONResponse ¶
type DecodeCodexAuthJSONResponse struct {
Credentials string `json:"credentials"`
}
type DoubaoHandlers ¶
type DoubaoHandlers struct {
VideoService *biz.VideoService
CreateOrchestrator *orchestrator.ChatCompletionOrchestrator
InboundTransformer *doubao.VideoInboundTransformer
}
func NewDoubaoHandlers ¶
func NewDoubaoHandlers(params DoubaoHandlersParams) *DoubaoHandlers
func (*DoubaoHandlers) CreateTask ¶
func (h *DoubaoHandlers) CreateTask(c *gin.Context)
func (*DoubaoHandlers) DeleteTask ¶
func (h *DoubaoHandlers) DeleteTask(c *gin.Context)
func (*DoubaoHandlers) GetTask ¶
func (h *DoubaoHandlers) GetTask(c *gin.Context)
type DoubaoHandlersParams ¶
type DoubaoHandlersParams struct {
fx.In
VideoService *biz.VideoService
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type DownloadContentRequest ¶
type DownloadContentRequest struct {
RequestID int `uri:"request_id"`
}
type ExchangeAntigravityOAuthRequest ¶
type ExchangeAntigravityOAuthRequest struct {
SessionID string `json:"session_id" binding:"required"`
CallbackURL string `json:"callback_url" binding:"required"`
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
}
type ExchangeAntigravityOAuthResponse ¶
type ExchangeAntigravityOAuthResponse struct {
Credentials string `json:"credentials"`
}
type ExchangeClaudeCodeOAuthRequest ¶
type ExchangeClaudeCodeOAuthRequest struct {
SessionID string `json:"session_id" binding:"required"`
CallbackURL string `json:"callback_url" binding:"required"`
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
}
type ExchangeClaudeCodeOAuthResponse ¶
type ExchangeClaudeCodeOAuthResponse struct {
Credentials string `json:"credentials"`
}
type ExchangeCodexOAuthRequest ¶
type ExchangeCodexOAuthRequest struct {
SessionID string `json:"session_id" binding:"required"`
CallbackURL string `json:"callback_url" binding:"required"`
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
}
type ExchangeCodexOAuthResponse ¶
type ExchangeCodexOAuthResponse struct {
Credentials string `json:"credentials"`
}
type GatewayHandlers ¶
type GatewayHandlers struct {
AdapterService *biz.AdapterService
}
GatewayHandlers 负责适配器配置管理的 REST API 处理器.
func NewGatewayHandlers ¶
func NewGatewayHandlers(params GatewayHandlersParams) *GatewayHandlers
NewGatewayHandlers 创建 Gateway 处理器.
func (*GatewayHandlers) DeleteAdapter ¶
func (h *GatewayHandlers) DeleteAdapter(c *gin.Context)
DeleteAdapter 软删除指定名称的适配器及其所有活跃绑定。 不存在时返回 404,已删除时也返回 404(幂等行为与现有项目习惯一致)。
func (*GatewayHandlers) GetRuntimeStatus ¶
func (h *GatewayHandlers) GetRuntimeStatus(c *gin.Context)
GetRuntimeStatus 返回当前适配器运行时状态.
func (*GatewayHandlers) ListAdapters ¶
func (h *GatewayHandlers) ListAdapters(c *gin.Context)
ListAdapters 返回所有适配器配置(包含绑定信息).
func (*GatewayHandlers) RefreshGateway ¶
func (h *GatewayHandlers) RefreshGateway(c *gin.Context)
RefreshGateway 手动触发适配器配置刷新.
func (*GatewayHandlers) RenameAdapter ¶
func (h *GatewayHandlers) RenameAdapter(c *gin.Context)
RenameAdapter 将适配器重命名为新名称。事务内完成:创建新适配器、迁移活跃绑定、软删除旧记录。 同名时返回当前配置(no-op)。
func (*GatewayHandlers) UpdateAdapter ¶
func (h *GatewayHandlers) UpdateAdapter(c *gin.Context)
UpdateAdapter 更新适配器配置,包含可选的整体绑定替换(事务操作)。
type GatewayHandlersParams ¶
type GatewayHandlersParams struct {
fx.In
AdapterService *biz.AdapterService
}
GatewayHandlersParams Gateway 处理器依赖参数.
type GeminiHandlers ¶
type GeminiHandlers struct {
ChannelService *biz.ChannelService
ModelService *biz.ModelService
ChatCompletionHandlers *ChatCompletionHandlers
}
func NewGeminiHandlers ¶
func NewGeminiHandlers(params GeminiHandlersParams) *GeminiHandlers
func (*GeminiHandlers) GenerateContent ¶
func (handlers *GeminiHandlers) GenerateContent(c *gin.Context)
func (*GeminiHandlers) ListModels ¶
func (handlers *GeminiHandlers) ListModels(c *gin.Context)
ListModels returns all available Gemini models. This endpoint is compatible with Gemini's /v1/models API. It uses QueryAllChannelModels setting from system config to determine model source.
type GeminiHandlersParams ¶
type GeminiHandlersParams struct {
fx.In
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type GeminiModel ¶
type GeminiModel struct {
Name string `json:"name"`
BaseModelID string `json:"baseModelId"`
Version string `json:"version"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
SupportedGenerationMethods []string `json:"supportedGenerationMethods"`
}
GeminiModel represents a model in the list models response.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
Version string `json:"version"`
Build build.Info `json:"build"`
Uptime string `json:"uptime"`
}
HealthResponse 健康检查响应.
type InitializeSystemRequest ¶
type InitializeSystemRequest struct {
OwnerEmail string `json:"ownerEmail" binding:"required,email"`
OwnerPassword string `json:"ownerPassword" binding:"required,min=6"`
OwnerFirstName string `json:"ownerFirstName" binding:"required"`
OwnerLastName string `json:"ownerLastName" binding:"required"`
BrandName string `json:"brandName" binding:"required"`
PreferLanguage string `json:"preferLanguage,omitempty"`
}
InitializeSystemRequest 系统初始化请求.
type InitializeSystemResponse ¶
type InitializeSystemResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
}
InitializeSystemResponse 系统初始化响应.
type JinaHandlers ¶
type JinaHandlers struct {
RerankHandlers *ChatCompletionHandlers
EmbeddingHandlers *ChatCompletionHandlers
}
func NewJinaHandlers ¶
func NewJinaHandlers(params JinaHandlersParams) *JinaHandlers
func (*JinaHandlers) CreateEmbedding ¶
func (h *JinaHandlers) CreateEmbedding(c *gin.Context)
func (*JinaHandlers) Rerank ¶
func (h *JinaHandlers) Rerank(c *gin.Context)
Rerank handles rerank requests.
type JinaHandlersParams ¶
type JinaHandlersParams struct {
fx.In
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type ListAdaptersResponse ¶
type ListAdaptersResponse struct {
Adapters []AdapterDTO `json:"adapters"`
}
ListAdaptersResponse 适配器列表响应.
type Modalities ¶
type OIDCHandlerParams ¶
type OIDCHandlerParams struct {
fx.In
OIDCService *biz.OIDCService
AuthService *biz.AuthService
PublicURL string `name:"public_url"`
}
type OIDCHandlers ¶
type OIDCHandlers struct {
// contains filtered or unexported fields
}
func NewOIDCHandlers ¶
func NewOIDCHandlers(params OIDCHandlerParams) *OIDCHandlers
func (*OIDCHandlers) Callback ¶
func (h *OIDCHandlers) Callback(c *gin.Context)
func (*OIDCHandlers) Exchange ¶
func (h *OIDCHandlers) Exchange(c *gin.Context)
func (*OIDCHandlers) GetAuthorizeURL ¶
func (h *OIDCHandlers) GetAuthorizeURL(c *gin.Context)
func (*OIDCHandlers) GetLinkAuthorizeURL ¶
func (h *OIDCHandlers) GetLinkAuthorizeURL(c *gin.Context)
func (*OIDCHandlers) GetProviders ¶
func (h *OIDCHandlers) GetProviders(c *gin.Context)
func (*OIDCHandlers) RegisterRoutes ¶
func (h *OIDCHandlers) RegisterRoutes(r gin.IRouter)
type OpenAIHandlers ¶
type OpenAIHandlers struct {
ChannelService *biz.ChannelService
ModelService *biz.ModelService
SystemService *biz.SystemService
VideoService *biz.VideoService
ChatCompletionHandlers *ChatCompletionHandlers
CompletionHandlers *ChatCompletionHandlers
ResponseCompletionHandlers *ChatCompletionHandlers
CompactHandlers *ChatCompletionHandlers
EmbeddingHandlers *ChatCompletionHandlers
ImageGenerationHandlers *ChatCompletionHandlers
ImageEditHandlers *ChatCompletionHandlers
ImageVariationHandlers *ChatCompletionHandlers
VideoHandlers *ChatCompletionHandlers
VideoInboundTransformer *openai.VideoInboundTransformer
SpeechHandlers *ChatCompletionHandlers
TranscriptionHandlers *ChatCompletionHandlers
TranslationHandlers *ChatCompletionHandlers
SpeechInboundTransformer *openai.AudioInboundTransformer
EntClient *ent.Client
}
func NewOpenAIHandlers ¶
func NewOpenAIHandlers(params OpenAIHandlersParams) *OpenAIHandlers
func (*OpenAIHandlers) ChatCompletion ¶
func (handlers *OpenAIHandlers) ChatCompletion(c *gin.Context)
func (*OpenAIHandlers) CompactResponse ¶
func (handlers *OpenAIHandlers) CompactResponse(c *gin.Context)
func (*OpenAIHandlers) Completion ¶
func (handlers *OpenAIHandlers) Completion(c *gin.Context)
func (*OpenAIHandlers) CreateEmbedding ¶
func (handlers *OpenAIHandlers) CreateEmbedding(c *gin.Context)
func (*OpenAIHandlers) CreateImage ¶
func (handlers *OpenAIHandlers) CreateImage(c *gin.Context)
func (*OpenAIHandlers) CreateImageEdit ¶
func (handlers *OpenAIHandlers) CreateImageEdit(c *gin.Context)
func (*OpenAIHandlers) CreateImageVariation ¶
func (handlers *OpenAIHandlers) CreateImageVariation(c *gin.Context)
func (*OpenAIHandlers) CreateResponse ¶
func (handlers *OpenAIHandlers) CreateResponse(c *gin.Context)
func (*OpenAIHandlers) CreateSpeech ¶
func (handlers *OpenAIHandlers) CreateSpeech(c *gin.Context)
CreateSpeech handles POST /v1/audio/speech (text-to-speech). The response is binary audio.
func (*OpenAIHandlers) CreateTranscription ¶
func (handlers *OpenAIHandlers) CreateTranscription(c *gin.Context)
CreateTranscription handles POST /v1/audio/transcriptions (speech-to-text).
func (*OpenAIHandlers) CreateTranslation ¶
func (handlers *OpenAIHandlers) CreateTranslation(c *gin.Context)
CreateTranslation handles POST /v1/audio/translations (speech-to-text translation).
func (*OpenAIHandlers) CreateVideo ¶
func (handlers *OpenAIHandlers) CreateVideo(c *gin.Context)
func (*OpenAIHandlers) DeleteVideo ¶
func (handlers *OpenAIHandlers) DeleteVideo(c *gin.Context)
func (*OpenAIHandlers) GetVideo ¶
func (handlers *OpenAIHandlers) GetVideo(c *gin.Context)
func (*OpenAIHandlers) ListModels ¶
func (handlers *OpenAIHandlers) ListModels(c *gin.Context)
ListModels returns all available models. This endpoint is compatible with OpenAI's /v1/models API. It uses QueryAllChannelModels setting from system config to determine model source.
func (*OpenAIHandlers) RetrieveModel ¶
func (handlers *OpenAIHandlers) RetrieveModel(c *gin.Context)
RetrieveModel returns a single available model. This endpoint is compatible with OpenAI's /v1/models/{model} API.
type OpenAIHandlersParams ¶
type OpenAIHandlersParams struct {
fx.In
VideoService *biz.VideoService
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
Client *ent.Client
}
type OpenAIModel ¶
type OpenAIModel struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ContextLength int `json:"context_length,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Modalities *Modalities `json:"modalities,omitempty"`
Capabilities *Capabilities `json:"capabilities,omitempty"`
Pricing *Pricing `json:"pricing,omitempty"`
Icon string `json:"icon,omitempty"`
Type string `json:"type,omitempty"`
}
type PlaygroundHandlers ¶
type PlaygroundHandlers struct {
ChannelService *biz.ChannelService
ChatCompletionOrchestrator *orchestrator.ChatCompletionOrchestrator
}
func NewPlaygroundHandlers ¶
func NewPlaygroundHandlers(params PlaygroundHandlersParams) *PlaygroundHandlers
func (*PlaygroundHandlers) ChatCompletion ¶
func (handlers *PlaygroundHandlers) ChatCompletion(c *gin.Context)
func (*PlaygroundHandlers) HandleError ¶
func (handlers *PlaygroundHandlers) HandleError(rawErr error) *PlaygroundResponseError
HandleError handles raw errors and returns a PlaygroundResponseError.
type PlaygroundHandlersParams ¶
type PlaygroundHandlersParams struct {
fx.In
ChannelService *biz.ChannelService
ModelService *biz.ModelService
DefaultSelector *orchestrator.DefaultSelector
RequestService *biz.RequestService
SystemService *biz.SystemService
UsageLogService *biz.UsageLogService
PromptService *biz.PromptService
PromptProtectionRuleService *biz.PromptProtectionRuleService
QuotaService *biz.QuotaService
HttpClient *httpclient.HttpClient
LiveStreamRegistry *biz.LiveStreamRegistry
ChannelLimiterManager *orchestrator.ChannelLimiterManager
ProviderQuotaStatusProvider orchestrator.ProviderQuotaStatusProvider
}
type PlaygroundResponseError ¶
type PollCopilotOAuthRequest ¶
type PollCopilotOAuthRequest struct {
SessionID string `json:"session_id" binding:"required"`
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
}
PollCopilotOAuthRequest represents the request body for polling OAuth token.
type PollCopilotOAuthResponse ¶
type PollCopilotOAuthResponse struct {
Token string `json:"access_token,omitempty"` //nolint:gosec
Type string `json:"token_type,omitempty"`
Scope string `json:"scope,omitempty"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
}
PollCopilotOAuthResponse represents the response for polling OAuth token.
type ProtocolDTO ¶
type ProtocolDTO struct {
ID int `json:"id"`
InboundAPIFormat string `json:"inbound_api_format"`
Enabled bool `json:"enabled"`
Remark *string `json:"remark,omitempty"`
Targets []TargetDTO `json:"targets"`
}
ProtocolDTO 协议数据传输对象.
type ProtocolInput ¶
type ProtocolInput struct {
InboundAPIFormat string `json:"inbound_api_format" binding:"required"`
Enabled bool `json:"enabled"`
Remark *string `json:"remark,omitempty"`
// Targets 整体替换
Targets []TargetInput `json:"targets,omitempty"`
}
ProtocolInput 协议输入.
type RenameAdapterRequest ¶
type RenameAdapterRequest struct {
NewName string `json:"new_name" binding:"required"`
}
RenameAdapterRequest 适配器重命名请求.
type RequestContentHandlers ¶
type RequestContentHandlers struct {
DataStorageService *biz.DataStorageService
}
func NewRequestContentHandlers ¶
func NewRequestContentHandlers(params RequestContentHandlersParams) *RequestContentHandlers
func (*RequestContentHandlers) DownloadRequestContent ¶
func (h *RequestContentHandlers) DownloadRequestContent(c *gin.Context)
type RequestContentHandlersParams ¶
type RequestContentHandlersParams struct {
fx.In
DataStorageService *biz.DataStorageService
}
type RequestDetailPreviewContract ¶
type RequestDetailPreviewContract struct {
SingleInstanceOnly bool
SupportsDistributedReplay bool
AllowsDatabaseSchemaChanges bool
ExecutionLevelPreview bool
EventOrder []string
Scope string
ReuseInMemoryChunkBuffer bool
FinalBatchPersistenceUnchanged bool
FallbackMode string
FallbackBehavior string
FallbackUsesExecutionPreview bool
FallbackStartsSecondaryLivePollingLoop bool
EndpointPath string
ContentType string
EventTypes []string
ReplayOmitsTerminalDoneEvent bool
IncrementalOmitsTerminalDoneEvent bool
ConnectAfterCompletionFallsBackToStaticFetch bool
}
func RequestDetailSSEContract ¶
func RequestDetailSSEContract() RequestDetailPreviewContract
type RequestPreviewFallbackResponse ¶
type RequestPreviewFallbackResponse struct {
Mode string `json:"mode"`
ResponseChunks []objects.JSONRawMessage `json:"responseChunks"`
}
type RequestPreviewHandlers ¶
type RequestPreviewHandlers struct {
RequestService *biz.RequestService
LiveStreamRegistry *biz.LiveStreamRegistry
StreamWriter StreamWriter
}
func NewRequestPreviewHandlers ¶
func NewRequestPreviewHandlers(params RequestPreviewHandlersParams) *RequestPreviewHandlers
func (*RequestPreviewHandlers) PreviewRequest ¶
func (h *RequestPreviewHandlers) PreviewRequest(c *gin.Context)
type RequestPreviewHandlersParams ¶
type RequestPreviewHandlersParams struct {
fx.In
RequestService *biz.RequestService
LiveStreamRegistry *biz.LiveStreamRegistry
}
type SignInRequest ¶
type SignInRequest struct {
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required"`
}
SignInRequest 登录请求.
type SignInResponse ¶
SignInResponse 登录响应.
type StartAntigravityOAuthRequest ¶
type StartAntigravityOAuthRequest struct {
ProjectID string `json:"project_id"`
}
type StartClaudeCodeOAuthRequest ¶
type StartClaudeCodeOAuthRequest struct{}
type StartCodexOAuthRequest ¶
type StartCodexOAuthRequest struct{}
type StartCodexOAuthResponse ¶
type StartCopilotOAuthRequest ¶
type StartCopilotOAuthRequest struct {
Proxy *httpclient.ProxyConfig `json:"proxy,omitempty"`
}
StartCopilotOAuthRequest represents the request body for starting OAuth device flow.
type StartCopilotOAuthResponse ¶
type StartCopilotOAuthResponse struct {
SessionID string `json:"session_id"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
StartCopilotOAuthResponse represents the response for starting OAuth device flow.
type StreamErrorFormatter ¶
StreamErrorFormatter formats a stream error into a JSON-serializable object for SSE error events.
type StreamWriter ¶
type StreamWriter func(c *gin.Context, stream streams.Stream[*httpclient.StreamEvent])
StreamWriter is a function type for writing stream events to the response.
type SystemHandlers ¶
type SystemHandlers struct {
SystemService *biz.SystemService
}
func NewSystemHandlers ¶
func NewSystemHandlers(params SystemHandlersParams) *SystemHandlers
func (*SystemHandlers) GetFavicon ¶
func (h *SystemHandlers) GetFavicon(c *gin.Context)
GetFavicon returns the system brand logo as favicon.
func (*SystemHandlers) GetSystemStatus ¶
func (h *SystemHandlers) GetSystemStatus(c *gin.Context)
GetSystemStatus returns the system initialization status.
func (*SystemHandlers) Health ¶
func (h *SystemHandlers) Health(c *gin.Context)
Health returns the application health status and build information.
func (*SystemHandlers) InitializeSystem ¶
func (h *SystemHandlers) InitializeSystem(c *gin.Context)
InitializeSystem initializes the system with owner credentials.
func (*SystemHandlers) WebhookEcho ¶
func (h *SystemHandlers) WebhookEcho(c *gin.Context)
WebhookEcho echos inbound webhook requests for validation.
type SystemHandlersParams ¶
type SystemHandlersParams struct {
fx.In
SystemService *biz.SystemService
}
type SystemStatusResponse ¶
type SystemStatusResponse struct {
IsInitialized bool `json:"isInitialized"`
}
SystemStatusResponse 系统状态响应.
type TargetCapabilitiesDTO ¶
type TargetCapabilitiesDTO struct {
SupportsTools bool `json:"supports_tools"`
SupportsStream bool `json:"supports_stream"`
// StreamPolicy 目标级流式响应策略:"unlimited"、"require"、"forbid"。空字符串按旧数据兼容处理。
StreamPolicy string `json:"stream_policy,omitempty"`
InputModalities []string `json:"input_modalities"`
OutputModalities []string `json:"output_modalities"`
}
TargetCapabilitiesDTO 目标能力数据传输对象.
type TargetDTO ¶
type TargetDTO struct {
ID int `json:"id"`
ChannelID int `json:"channel_id"`
TargetModelID string `json:"target_model_id"`
Priority int `json:"priority"`
Enabled bool `json:"enabled"`
Remark *string `json:"remark,omitempty"`
Capabilities TargetCapabilitiesDTO `json:"capabilities"`
}
TargetDTO 目标数据传输对象.
type TargetInput ¶
type TargetInput struct {
ChannelID int `json:"channel_id" binding:"required"`
TargetModelID string `json:"target_model_id" binding:"required"`
Priority int `json:"priority"`
Enabled bool `json:"enabled"`
Remark *string `json:"remark,omitempty"`
Capabilities TargetCapabilitiesDTO `json:"capabilities"`
}
TargetInput 目标输入.
type UpdateAdapterRequest ¶
type UpdateAdapterRequest struct {
DisplayName string `json:"display_name"`
InboundAPIFormat string `json:"inbound_api_format"` // 创建时必填,更新时忽略
Status string `json:"status"`
Remark *string `json:"remark,omitempty"`
// Bindings 整体替换:传入完整的新绑定列表,不传则保留现有绑定
Bindings []BindingInput `json:"bindings,omitempty"`
}
UpdateAdapterRequest 更新适配器请求.