Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/ajiany_nanobot-golang.json
T

1 line
9.6 KiB
JSON

{"repo": "ajiany/nanobot-golang", "files": {"internal/providers/registry.go": {"05ec9e5b996475b32b184ca5508e424bf0f0311f": {"t": 1785745647.119329, "n": 4407, "h": "faf37dc8f6b31aa8", "c": "package providers\n\nimport \"strings\"\n\ntype ProviderSpec struct {\n\tName string\n\tKeywords []string // model name keywords for matching\n\tEnvKey string // environment variable for API key\n\tDefaultAPIBase string // default base URL\n\tIsGateway bool // multi-provider gateway (OpenRouter, AiHubMix)\n\tIsLocal bool // local inference (Ollama, vLLM)\n\tIsDirect bool // bypass litellm, use direct HTTP\n\tIsOAuth bool // OAuth authentication\n\tDetectByKeyPrefix string // detect by API key prefix (e.g. \"sk-or-\" for OpenRouter)\n\tDetectByBaseKW string // detect by base URL keyword\n\tModelPrefix string // prefix to add to model name\n\tSkipPrefixes []string // prefixes to skip when adding ModelPrefix\n\tPromptCaching bool // supports prompt caching\n\tModelOverrides map[string]map[string]any // per-model parameter overrides\n}\n\n// Providers is the complete registry of known LLM providers\nvar Providers = []ProviderSpec{\n\t{Name: \"openrouter\", Keywords: []string{\"openrouter\"}, EnvKey: \"OPENROUTER_API_KEY\", DefaultAPIBase: \"https://openrouter.ai/api/v1\", IsGateway: true, DetectByKeyPrefix: \"sk-or-\"},\n\t{Name: \"aihubmix\", Keywords: []string{\"aihubmix\"}, EnvKey: \"AIHUBMIX_API_KEY\", DefaultAPIBase: \"https://aihubmix.com/v1\", IsGateway: true, DetectByKeyPrefix: \"sk-aihub\"},\n\t{Name: \"anthropic\", Keywords: []string{\"claude\", \"anthropic\"}, EnvKey: \"ANTHROPIC_API_KEY\", PromptCaching: true},\n\t{Name: \"openai\", Keywords: []string{\"gpt\", \"o1\", \"o3\", \"chatgpt\"}, EnvKey: \"OPENAI_API_KEY\", PromptCaching: true},\n\t{Name: \"deepseek\", Keywords: []string{\"deepseek\"}, EnvKey: \"DEEPSEEK_API_KEY\", DefaultAPIBase: \"https://api.deepseek.com/v1\"},\n\t{Name: \"moonshot\", Keywords: []string{\"moonshot\", \"kimi\"}, EnvKey: \"MOONSHOT_API_KEY\", DefaultAPIBase: \"https://api.moonshot.cn/v1\"},\n\t{Name: \"zhipu\", Keywords: []string{\"glm\", \"zhipu\"}, EnvKey: \"ZHIPUAI_API_KEY\", DefaultAPIBase: \"https://open.bigmodel.cn/api/paas/v4\"},\n\t{Name: \"dashscope\", Keywords: []string{\"qwen\", \"dashscope\"}, EnvKey: \"DASHSCOPE_API_KEY\", DefaultAPIBase: \"https://dashscope.aliyuncs.com/compatible-mode/v1\"},\n\t{Name: \"minimax\", Keywords: []string{\"minimax\", \"abab\"}, EnvKey: \"MINIMAX_API_KEY\", DefaultAPIBase: \"https://api.minimax.chat/v1\"},\n\t{Name: \"stepfun\", Keywords: []string{\"step\"}, EnvKey: \"STEPFUN_API_KEY\", DefaultAPIBase: \"https://api.stepfun.com/v1\"},\n\t{Name: \"groq\", Keywords: []string{\"groq\"}, EnvKey: \"GROQ_API_KEY\", DefaultAPIBase: \"https://api.groq.com/openai/v1\"},\n\t{Name: \"xai\", Keywords: []string{\"grok\", \"xai\"}, EnvKey: \"XAI_API_KEY\", DefaultAPIBase: \"https://api.x.ai/v1\"},\n\t{Name: \"mistral\", Keywords: []string{\"mistral\", \"mixtral\", \"codestral\"}, EnvKey: \"MISTRAL_API_KEY\", DefaultAPIBase: \"https://api.mistral.ai/v1\"},\n\t{Name: \"cohere\", Keywords: []string{\"command\"}, EnvKey: \"COHERE_API_KEY\", DefaultAPIBase: \"https://api.cohere.com/v2\"},\n\t{Name: \"gemini\", Keywords: []string{\"gemini\"}, EnvKey: \"GOOGLE_API_KEY\"},\n\t{Name: \"ollama\", Keywords: []string{\"ollama\"}, DefaultAPIBase: \"http://localhost:11434/v1\", IsLocal: true, DetectByBaseKW: \"11434\"},\n\t{Name: \"vllm\", Keywords: []string{\"vllm\"}, IsLocal: true, IsGateway: true, DetectByBaseKW: \"vllm\"},\n\t{Name: \"codex\", Keywords: []string{\"codex\"}, IsOAuth: true, IsDirect: true},\n\t{Name: \"custom\", IsDirect: true},\n}\n\n// FindByModel matches model name against Keywords, returns first match.\nfunc FindByModel(model string) *ProviderSpec {\n\tlower := strings.ToLower(model)\n\tfor i := range Providers {\n\t\tfor _, kw := range Providers[i].Keywords {\n\t\t\tif strings.Contains(lower, kw) {\n\t\t\t\treturn &Providers[i]\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// FindGateway detects a gateway provider by API key prefix or base URL keyword.\nfunc FindGateway(apiKey, baseURL string) *ProviderSpec {\n\tfor i := range Providers {\n\t\tspec := &Providers[i]\n\t\tif spec.DetectByKeyPrefix != \"\" && strings.HasPrefix(apiKey, spec.DetectByKeyPrefix) {\n\t\t\treturn spec\n\t\t}\n\t\tif spec.DetectByBaseKW != \"\" && strings.Contains(baseURL, spec.DetectByBaseKW) {\n\t\t\treturn spec\n\t\t}\n\t}\n\treturn nil\n}\n\n// FindByName returns the provider spec with an exact name match.\nfunc FindByName(name string) *ProviderSpec {\n\tfor i := range Providers {\n\t\tif Providers[i].Name == name {\n\t\t\treturn &Providers[i]\n\t\t}\n\t}\n\treturn nil\n}\n"}, "2a114a0b2ab6774a6c3303b260f483c43e9d92bd": {"t": 1785755334.937026, "n": 4407, "h": "faf37dc8f6b31aa8", "c": "package providers\n\nimport \"strings\"\n\ntype ProviderSpec struct {\n\tName string\n\tKeywords []string // model name keywords for matching\n\tEnvKey string // environment variable for API key\n\tDefaultAPIBase string // default base URL\n\tIsGateway bool // multi-provider gateway (OpenRouter, AiHubMix)\n\tIsLocal bool // local inference (Ollama, vLLM)\n\tIsDirect bool // bypass litellm, use direct HTTP\n\tIsOAuth bool // OAuth authentication\n\tDetectByKeyPrefix string // detect by API key prefix (e.g. \"sk-or-\" for OpenRouter)\n\tDetectByBaseKW string // detect by base URL keyword\n\tModelPrefix string // prefix to add to model name\n\tSkipPrefixes []string // prefixes to skip when adding ModelPrefix\n\tPromptCaching bool // supports prompt caching\n\tModelOverrides map[string]map[string]any // per-model parameter overrides\n}\n\n// Providers is the complete registry of known LLM providers\nvar Providers = []ProviderSpec{\n\t{Name: \"openrouter\", Keywords: []string{\"openrouter\"}, EnvKey: \"OPENROUTER_API_KEY\", DefaultAPIBase: \"https://openrouter.ai/api/v1\", IsGateway: true, DetectByKeyPrefix: \"sk-or-\"},\n\t{Name: \"aihubmix\", Keywords: []string{\"aihubmix\"}, EnvKey: \"AIHUBMIX_API_KEY\", DefaultAPIBase: \"https://aihubmix.com/v1\", IsGateway: true, DetectByKeyPrefix: \"sk-aihub\"},\n\t{Name: \"anthropic\", Keywords: []string{\"claude\", \"anthropic\"}, EnvKey: \"ANTHROPIC_API_KEY\", PromptCaching: true},\n\t{Name: \"openai\", Keywords: []string{\"gpt\", \"o1\", \"o3\", \"chatgpt\"}, EnvKey: \"OPENAI_API_KEY\", PromptCaching: true},\n\t{Name: \"deepseek\", Keywords: []string{\"deepseek\"}, EnvKey: \"DEEPSEEK_API_KEY\", DefaultAPIBase: \"https://api.deepseek.com/v1\"},\n\t{Name: \"moonshot\", Keywords: []string{\"moonshot\", \"kimi\"}, EnvKey: \"MOONSHOT_API_KEY\", DefaultAPIBase: \"https://api.moonshot.cn/v1\"},\n\t{Name: \"zhipu\", Keywords: []string{\"glm\", \"zhipu\"}, EnvKey: \"ZHIPUAI_API_KEY\", DefaultAPIBase: \"https://open.bigmodel.cn/api/paas/v4\"},\n\t{Name: \"dashscope\", Keywords: []string{\"qwen\", \"dashscope\"}, EnvKey: \"DASHSCOPE_API_KEY\", DefaultAPIBase: \"https://dashscope.aliyuncs.com/compatible-mode/v1\"},\n\t{Name: \"minimax\", Keywords: []string{\"minimax\", \"abab\"}, EnvKey: \"MINIMAX_API_KEY\", DefaultAPIBase: \"https://api.minimax.chat/v1\"},\n\t{Name: \"stepfun\", Keywords: []string{\"step\"}, EnvKey: \"STEPFUN_API_KEY\", DefaultAPIBase: \"https://api.stepfun.com/v1\"},\n\t{Name: \"groq\", Keywords: []string{\"groq\"}, EnvKey: \"GROQ_API_KEY\", DefaultAPIBase: \"https://api.groq.com/openai/v1\"},\n\t{Name: \"xai\", Keywords: []string{\"grok\", \"xai\"}, EnvKey: \"XAI_API_KEY\", DefaultAPIBase: \"https://api.x.ai/v1\"},\n\t{Name: \"mistral\", Keywords: []string{\"mistral\", \"mixtral\", \"codestral\"}, EnvKey: \"MISTRAL_API_KEY\", DefaultAPIBase: \"https://api.mistral.ai/v1\"},\n\t{Name: \"cohere\", Keywords: []string{\"command\"}, EnvKey: \"COHERE_API_KEY\", DefaultAPIBase: \"https://api.cohere.com/v2\"},\n\t{Name: \"gemini\", Keywords: []string{\"gemini\"}, EnvKey: \"GOOGLE_API_KEY\"},\n\t{Name: \"ollama\", Keywords: []string{\"ollama\"}, DefaultAPIBase: \"http://localhost:11434/v1\", IsLocal: true, DetectByBaseKW: \"11434\"},\n\t{Name: \"vllm\", Keywords: []string{\"vllm\"}, IsLocal: true, IsGateway: true, DetectByBaseKW: \"vllm\"},\n\t{Name: \"codex\", Keywords: []string{\"codex\"}, IsOAuth: true, IsDirect: true},\n\t{Name: \"custom\", IsDirect: true},\n}\n\n// FindByModel matches model name against Keywords, returns first match.\nfunc FindByModel(model string) *ProviderSpec {\n\tlower := strings.ToLower(model)\n\tfor i := range Providers {\n\t\tfor _, kw := range Providers[i].Keywords {\n\t\t\tif strings.Contains(lower, kw) {\n\t\t\t\treturn &Providers[i]\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// FindGateway detects a gateway provider by API key prefix or base URL keyword.\nfunc FindGateway(apiKey, baseURL string) *ProviderSpec {\n\tfor i := range Providers {\n\t\tspec := &Providers[i]\n\t\tif spec.DetectByKeyPrefix != \"\" && strings.HasPrefix(apiKey, spec.DetectByKeyPrefix) {\n\t\t\treturn spec\n\t\t}\n\t\tif spec.DetectByBaseKW != \"\" && strings.Contains(baseURL, spec.DetectByBaseKW) {\n\t\t\treturn spec\n\t\t}\n\t}\n\treturn nil\n}\n\n// FindByName returns the provider spec with an exact name match.\nfunc FindByName(name string) *ProviderSpec {\n\tfor i := range Providers {\n\t\tif Providers[i].Name == name {\n\t\t\treturn &Providers[i]\n\t\t}\n\t}\n\treturn nil\n}\n"}}}}