Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed). - CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels - New CheckinButton in both authenticated and public headers (Turnstile supported) - New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset - New /docs 12-section beginner guide with anchor navigation - New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi) - README: document custom features, live demo https://ai.88531.cn
36 lines
1.6 KiB
Go
36 lines
1.6 KiB
Go
package common
|
|
|
|
import "github.com/QuantumNous/new-api/constant"
|
|
|
|
// EndpointInfo 描述单个端点的默认请求信息
|
|
// path: 上游路径
|
|
// method: HTTP 请求方式,例如 POST/GET
|
|
// 目前均为 POST,后续可扩展
|
|
//
|
|
// json 标签用于直接序列化到 API 输出
|
|
// 例如:{"path":"/v1/chat/completions","method":"POST"}
|
|
|
|
type EndpointInfo struct {
|
|
Path string `json:"path"`
|
|
Method string `json:"method"`
|
|
}
|
|
|
|
// defaultEndpointInfoMap 保存内置端点的默认 Path 与 Method
|
|
var defaultEndpointInfoMap = map[constant.EndpointType]EndpointInfo{
|
|
constant.EndpointTypeOpenAI: {Path: "/v1/chat/completions", Method: "POST"},
|
|
constant.EndpointTypeOpenAIResponse: {Path: "/v1/responses", Method: "POST"},
|
|
constant.EndpointTypeOpenAIResponseCompact: {Path: "/v1/responses/compact", Method: "POST"},
|
|
constant.EndpointTypeOpenAIAlphaSearch: {Path: "/v1/alpha/search", Method: "POST"},
|
|
constant.EndpointTypeAnthropic: {Path: "/v1/messages", Method: "POST"},
|
|
constant.EndpointTypeGemini: {Path: "/v1beta/models/{model}:generateContent", Method: "POST"},
|
|
constant.EndpointTypeJinaRerank: {Path: "/v1/rerank", Method: "POST"},
|
|
constant.EndpointTypeImageGeneration: {Path: "/v1/images/generations", Method: "POST"},
|
|
constant.EndpointTypeEmbeddings: {Path: "/v1/embeddings", Method: "POST"},
|
|
}
|
|
|
|
// GetDefaultEndpointInfo 返回指定端点类型的默认信息以及是否存在
|
|
func GetDefaultEndpointInfo(et constant.EndpointType) (EndpointInfo, bool) {
|
|
info, ok := defaultEndpointInfoMap[et]
|
|
return info, ok
|
|
}
|