93 lines
3.3 KiB
Go
93 lines
3.3 KiB
Go
package response
|
||
|
||
import (
|
||
"encoding/json"
|
||
"time"
|
||
)
|
||
|
||
// ProviderResponse 提供商响应
|
||
type ProviderResponse struct {
|
||
ID uint `json:"id"`
|
||
ProviderName string `json:"providerName"`
|
||
ProviderType string `json:"providerType"`
|
||
BaseURL string `json:"baseUrl"`
|
||
APIKeySet bool `json:"apiKeySet"` // 是否已设置API密钥(不返回明文)
|
||
APIKeyHint string `json:"apiKeyHint"` // API密钥提示(如 sk-****1234)
|
||
APIConfig json.RawMessage `json:"apiConfig"`
|
||
Capabilities json.RawMessage `json:"capabilities"`
|
||
IsEnabled bool `json:"isEnabled"`
|
||
IsDefault bool `json:"isDefault"`
|
||
SortOrder int `json:"sortOrder"`
|
||
Models []ModelResponse `json:"models"`
|
||
CreatedAt time.Time `json:"createdAt"`
|
||
UpdatedAt time.Time `json:"updatedAt"`
|
||
}
|
||
|
||
// ModelResponse 模型响应
|
||
type ModelResponse struct {
|
||
ID uint `json:"id"`
|
||
ProviderID uint `json:"providerId"`
|
||
ModelName string `json:"modelName"`
|
||
DisplayName string `json:"displayName"`
|
||
ModelType string `json:"modelType"`
|
||
Config json.RawMessage `json:"config"`
|
||
IsEnabled bool `json:"isEnabled"`
|
||
CreatedAt time.Time `json:"createdAt"`
|
||
}
|
||
|
||
// ProviderListResponse 提供商列表响应
|
||
type ProviderListResponse struct {
|
||
List []ProviderResponse `json:"list"`
|
||
Total int64 `json:"total"`
|
||
Page int `json:"page"`
|
||
PageSize int `json:"pageSize"`
|
||
}
|
||
|
||
// TestProviderResponse 测试连通性响应
|
||
type TestProviderResponse struct {
|
||
Success bool `json:"success"`
|
||
Message string `json:"message"`
|
||
Models []string `json:"models,omitempty"` // 获取到的可用模型列表
|
||
Latency int64 `json:"latency"` // 响应延迟(毫秒)
|
||
}
|
||
|
||
// ProviderTypeOption 提供商类型选项(前端下拉用)
|
||
type ProviderTypeOption struct {
|
||
Value string `json:"value"` // 类型标识
|
||
Label string `json:"label"` // 显示名称
|
||
Description string `json:"description"` // 描述
|
||
DefaultURL string `json:"defaultUrl"` // 默认API地址
|
||
}
|
||
|
||
// PresetModelOption 预设模型选项
|
||
type PresetModelOption struct {
|
||
ModelName string `json:"modelName"`
|
||
DisplayName string `json:"displayName"`
|
||
ModelType string `json:"modelType"` // chat / image_gen
|
||
}
|
||
|
||
// RemoteModel 远程获取到的模型信息
|
||
type RemoteModel struct {
|
||
ID string `json:"id"` // 模型标识(API调用用)
|
||
DisplayName string `json:"displayName"` // 显示名称
|
||
OwnedBy string `json:"ownedBy"` // 所有者/来源
|
||
}
|
||
|
||
// FetchRemoteModelsResponse 获取远程模型列表响应
|
||
type FetchRemoteModelsResponse struct {
|
||
Success bool `json:"success"`
|
||
Message string `json:"message"`
|
||
Models []RemoteModel `json:"models"`
|
||
Latency int64 `json:"latency"` // 响应延迟(毫秒)
|
||
}
|
||
|
||
// SendTestMessageResponse 发送测试消息响应
|
||
type SendTestMessageResponse struct {
|
||
Success bool `json:"success"`
|
||
Message string `json:"message"` // 状态信息
|
||
Reply string `json:"reply"` // AI 回复内容
|
||
Model string `json:"model"` // 实际使用的模型
|
||
Latency int64 `json:"latency"` // 响应延迟(毫秒)
|
||
Tokens int `json:"tokens"` // 消耗的token数
|
||
}
|