Documentation
¶
Index ¶
Constants ¶
const ( Unknown = iota OpenAI API2D Azure CloseAI OpenAISB OpenAIMax OhMyGPT Custom Ails AIProxy PaLM API2GPT AIGC2D Anthropic Baidu Zhipu Ali Xunfei AI360 OpenRouter AIProxyLibrary FastGPT Tencent Gemini Moonshot Baichuan Minimax Mistral Groq Ollama LingYiWanWu StepFun AwsClaude Coze Cohere DeepSeek Cloudflare DeepL TogetherAI Doubao Novita VertextAI Proxy SiliconFlow XAI Replicate BaiduV2 XunfeiV2 AliBailian OpenAICompatible GeminiOpenAICompatible Codex ChatGPTSub Dummy )
Variables ¶
var ChannelBaseURLs = map[int]string{
0: "",
1: "https://api.openai.com",
2: "https://oa.api2d.net",
3: "",
4: "https://api.closeai-proxy.xyz",
5: "https://api.openai-sb.com",
6: "https://api.openaimax.com",
7: "https://api.ohmygpt.com",
8: "",
9: "https://api.caipacity.com",
10: "https://api.aiproxy.io",
11: "https://generativelanguage.googleapis.com",
12: "https://api.api2gpt.com",
13: "https://api.aigc2d.com",
14: "https://api.anthropic.com",
15: "https://aip.baidubce.com",
16: "https://open.bigmodel.cn",
17: "https://dashscope.aliyuncs.com",
18: "",
19: "https://ai.360.cn",
20: "https://openrouter.ai/api",
21: "https://api.aiproxy.io",
22: "https://fastgpt.run/api/openapi",
23: "https://hunyuan.tencentcloudapi.com",
24: "https://generativelanguage.googleapis.com",
25: "https://api.moonshot.cn",
26: "https://api.baichuan-ai.com",
27: "https://api.minimax.chat",
28: "https://api.mistral.ai",
29: "https://api.groq.com/openai",
30: "http://localhost:11434",
31: "https://api.lingyiwanwu.com",
32: "https://api.stepfun.com",
33: "",
34: "https://api.coze.com",
35: "https://api.cohere.com",
36: "https://api.deepseek.com",
37: "https://api.cloudflare.com",
38: "https://api-free.deepl.com",
39: "https://api.together.xyz",
40: "https://ark.cn-beijing.volces.com",
41: "https://api.novita.ai/v3/openai",
42: "",
43: "",
44: "https://api.siliconflow.cn",
45: "https://api.x.ai",
46: "https://api.replicate.com/v1/models/",
47: "https://qianfan.baidubce.com",
48: "https://spark-api-open.xf-yun.com",
49: "https://dashscope.aliyuncs.com",
50: "",
51: "https://generativelanguage.googleapis.com/v1beta/openai/",
52: "",
53: "https://chatgpt.com",
}
ChannelBaseURLs 是内置渠道类型的默认 BaseURL 表,key 为渠道类型。
用 map 而非 slice:缺失的渠道类型返回零值 ""(比 slice 越界 panic 更安全), 且外部扩展方的扩展渠道无需在本表占位——扩展方按需自行维护其默认 BaseURL。
Functions ¶
func RegisterAPIType ¶ added in v1.0.1
RegisterAPIType 登记一个「渠道类型 → API 类型」映射(供外部扩展方在 init() 期调用)。
约定:本注册表用于**扩展渠道**——即内置范围(0 .. Dummy-1)之外的新渠道类型。查找优先于 内置 switch(保持「注册表优先」语义),因此把**内置**渠道类型登记进来会覆盖其内置映射, 这几乎总是误用(例如把内置 OpenAI 劫持到别的 adaptor)。为避免静默劫持,channelType 落在 内置范围内时记录一条告警日志;**不 panic、不阻断**,注册仍然生效(保持既有语义不变)。
同一 channelType 重复注册为「后写覆盖」语义:便于扩展方在测试或多阶段装配中重装。 查找发生在运行时,注册发生在 init() 期,故用 RWMutex 保护并发读写。
func RegisteredChannelTypes ¶ added in v1.0.1
func RegisteredChannelTypes() []int
RegisteredChannelTypes 返回当前所有已登记的扩展渠道类型(升序)。
与 RegisterAPIType 面向**外部扩展方**不同,本函数面向**本仓消费方**:供本仓在 不硬编码任何具体扩展渠道的前提下,枚举「内置范围(0 .. Dummy-1)之外」的渠道类型 (例如构建模型清单时把扩展渠道一并纳入),从而做到「新增扩展渠道时本仓一行代码都不用改」。
返回副本而非内部切片,调用方可自由遍历/修改而不影响注册表。升序是为了让结果确定, 便于消费方与测试做稳定断言(map 迭代本身无序)。
func ToAPIType ¶
ToAPIType 把渠道类型映射为 API 类型。
先查外部注册表(RegisterAPIType 登记),命中即返回;未命中再走内置 switch(内置渠道)。 这样扩展方新增的渠道无需在本仓登记,未注册的渠道类型按既有语义回退到 OpenAI。
func UnregisterAPIType ¶ added in v1.0.1
func UnregisterAPIType(channelType int)
UnregisterAPIType 注销一个此前经 RegisterAPIType 登记的「渠道类型 → API 类型」映射。
与 RegisterAPIType 配套,供多阶段装配或测试在收尾时还原全局注册表,避免残留登记项 遮蔽内置映射。未登记的 channelType 调用本函数为空操作。
Types ¶
This section is empty.