1 line
9.0 KiB
JSON
1 line
9.0 KiB
JSON
{"repo": "c-wenlong/quiver", "files": {"src/quiver/providers/defaults.py": {"5373a2e39a6e6f8b7971f600b0b16cb6f5484e2c": {"t": 1785674632.4628458, "n": 8235, "h": "680dd6c1f49500d1", "c": "\"\"\"Built-in default provider registry (seeded on first run).\n\nEach entry stores *metadata only* — the filename to look for inside\nthe user's keys directory, the canonical slug, the dashboard URL,\nand any env-var names that downstream tools use. No key strings live here.\n\nThe set of built-ins is curated against a real-world ``~/.api_keys``\nexport file (shell-style: ``export OPENAI_API_KEY=sk-...``). Providers\nnot in your personal file can still be added at runtime with\n``swe providers add``.\n\nDisplay ``name`` and ``alias`` fields are no longer persisted — they\nare *derived* from ``env_vars[0]`` at load time (see ``display_name``\nand ``derived_alias``) so the catalog has a single source of truth:\nthe env-var name itself. Manual aliases are not supported.\n\"\"\"\n\n# Known env-var suffixes, ordered longest-first so ``_HUB_TOKEN`` is\n# stripped before ``_TOKEN`` can accidentally match it.\n_STRIPPABLE_SUFFIXES = (\"_API_KEY\", \"_HUB_TOKEN\", \"_TOKEN\")\n\n\ndef _strip_suffix(env_var: str) -> str:\n \"\"\"Strip a known env-var suffix (``_API_KEY``, ``_HUB_TOKEN``, ``_TOKEN``).\"\"\"\n for suffix in _STRIPPABLE_SUFFIXES:\n if env_var.endswith(suffix):\n return env_var[: -len(suffix)]\n return env_var\n\n\ndef display_name(info: dict) -> str:\n \"\"\"Derive the human-readable name from ``env_vars[0]``.\n\n Strips a known suffix, replaces underscores with spaces, title-cases\n each word, and preserves the canonical ``AI`` capitalization\n (``TOGETHER_AI`` → ``Together AI``, not ``Together Ai``).\n \"\"\"\n env_vars = info.get(\"env_vars\") or []\n if not env_vars:\n return \"\"\n stripped = _strip_suffix(env_vars[0])\n titled = stripped.replace(\"_\", \" \").title()\n return titled.replace(\" Ai\", \" AI\")\n\n\ndef derived_alias(info: dict) -> str | None:\n \"\"\"Derive the auto-alias: env-var prefix lowercased, ``_`` → ``-``.\n\n Returns ``None`` when no env-var is configured (the provider would\n then be matched only by its canonical slug).\n \"\"\"\n env_vars = info.get(\"env_vars\") or []\n if not env_vars:\n return None\n stripped = _strip_suffix(env_vars[0])\n if not stripped:\n return None\n return stripped.lower().replace(\"_\", \"-\")\n\n\nDEFAULT_PROVIDERS = {\n \"openai\": {\n \"description\": \"OpenAI API (ChatGPT, GPT-4/5, DALL-E)\",\n \"url\": \"https://platform.openai.com/api-keys\",\n \"key_filename\": \"openai\",\n \"env_vars\": [\"OPENAI_API_KEY\"],\n },\n \"anthropic\": {\n \"description\": \"Anthropic Claude API\",\n \"url\": \"https://console.anthropic.com/settings/keys\",\n \"key_filename\": \"anthropic\",\n \"env_vars\": [\"ANTHROPIC_API_KEY\"],\n },\n \"gemini\": {\n \"description\": \"Google Gemini / AI Studio\",\n \"url\": \"https://aistudio.google.com/app/apikey\",\n \"key_filename\": \"gemini\",\n \"env_vars\": [\"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"],\n },\n \"deepseek\": {\n \"description\": \"DeepSeek API\",\n \"url\": \"https://platform.deepseek.com/api_keys\",\n \"key_filename\": \"deepseek\",\n \"env_vars\": [\"DEEPSEEK_API_KEY\"],\n },\n \"zai\": {\n \"description\": \"ZAI / 01.ai inference\",\n \"url\": \"https://z.ai/\",\n \"key_filename\": \"zai\",\n \"env_vars\": [\"ZAI_API_KEY\"],\n },\n \"minimax\": {\n \"description\": \"MiniMax inference\",\n \"url\": \"https://minimax.io/\",\n \"key_filename\": \"minimax\",\n \"env_vars\": [\"MINIMAX_API_KEY\"],\n },\n \"kimi\": {\n \"description\": \"Moonshot AI Kimi API\",\n \"url\": \"https://platform.moonshot.ai/\",\n \"key_filename\": \"kimi\",\n # KIMI_API_KEY is the newer Kimi-branded env var; MOONSHOT_API_KEY\n # is the canonical Moonshot SDK env var. Some users have only one.\n \"env_vars\": [\"KIMI_API_KEY\", \"MOONSHOT_API_KEY\"],\n },\n \"qwen\": {\n \"description\": \"Alibaba Qwen / Bailian / DashScope\",\n \"url\": \"https://bailian.console.aliyun.com/\",\n \"key_filename\": \"qwen\",\n # DASHSCOPE_API_KEY is the Alibaba DashScope SDK env var;\n # QWEN_API_KEY is recognized in some custom wrappers.\n \"env_vars\": [\"QWEN_API_KEY\", \"DASHSCOPE_API_KEY\"],\n },\n \"mimo\": {\n \"description\": \"Xiaomi MiMo model API\",\n \"url\": \"https://platform.xiaomi.com/\",\n \"key_filename\": \"mimo\",\n \"env_vars\": [\"MIMO_API_KEY\"],\n },\n \"xai\": {\n \"description\": \"xAI (Grok)\",\n \"url\": \"https://console.x.ai/\",\n \"key_filename\": \"xai\",\n \"env_vars\": [\"XAI_API_KEY\"],\n },\n \"stepfun\": {\n \"description\": \"StepFun inference API\",\n \"url\": \"https://platform.stepfun.ai/\",\n \"key_filename\": \"stepfun\",\n \"env_vars\": [\"STEPFUN_API_KEY\"],\n },\n \"groq\": {\n \"description\": \"Groq fast-inference API\",\n \"url\": \"https://console.groq.com/keys\",\n \"key_filename\": \"groq\",\n \"env_vars\": [\"GROQ_API_KEY\"],\n },\n \"upstage\": {\n \"description\": \"Upstage Solar API\",\n \"url\": \"https://console.upstage.ai/\",\n \"key_filename\": \"upstage\",\n \"env_vars\": [\"UPSTAGE_API_KEY\"],\n },\n \"cerebras\": {\n \"description\": \"Cerebras inference cloud\",\n \"url\": \"https://cloud.cerebras.ai/\",\n \"key_filename\": \"cerebras\",\n \"env_vars\": [\"CEREBRAS_API_KEY\"],\n },\n \"mistral\": {\n \"description\": \"Mistral inference API\",\n \"url\": \"https://console.mistral.ai/api-keys/\",\n \"key_filename\": \"mistral\",\n \"env_vars\": [\"MISTRAL_API_KEY\"],\n },\n \"routing_run\": {\n \"description\": \"Routing.Run\",\n \"url\": \"https://routing.run/\",\n \"key_filename\": \"routing_run\",\n \"env_vars\": [\"ROUTING_RUN_API_KEY\"],\n },\n \"opencode_zen\": {\n \"description\": \"Opencode Zen inference\",\n \"url\": \"https://opencode.ai/zen\",\n \"key_filename\": \"opencode_zen\",\n \"env_vars\": [\"OPENCODE_ZEN_API_KEY\"],\n },\n \"openrouter\": {\n \"description\": \"Unified router across many LLM providers\",\n \"url\": \"https://openrouter.ai/keys\",\n \"key_filename\": \"openrouter\",\n \"env_vars\": [\"OPENROUTER_API_KEY\"],\n },\n \"together_ai\": {\n \"description\": \"Together AI inference API\",\n \"url\": \"https://api.together.xyz/\",\n \"key_filename\": \"together\",\n # Both spellings appear in userland: TOGETHER_AI_API_KEY (newer)\n # and TOGETHER_API_KEY (older SDKs).\n \"env_vars\": [\"TOGETHER_AI_API_KEY\", \"TOGETHER_API_KEY\"],\n },\n \"fireworks_ai\": {\n \"description\": \"Fireworks AI inference cloud\",\n \"url\": \"https://fireworks.ai/\",\n \"key_filename\": \"fireworks\",\n \"env_vars\": [\"FIREWORKS_AI_API_KEY\"],\n },\n \"vercel_gateway\": {\n \"description\": \"Vercel AI Gateway\",\n \"url\": \"https://vercel.com/docs/ai-gateway\",\n \"key_filename\": \"vercel_gateway\",\n \"env_vars\": [\"VERCEL_GATEWAY_API_KEY\"],\n },\n \"nebius\": {\n \"description\": \"Nebius inference studio\",\n \"url\": \"https://studio.nebius.com/\",\n \"key_filename\": \"nebius\",\n \"env_vars\": [\"NEBIUS_API_KEY\"],\n },\n \"featherless\": {\n \"description\": \"Featherless AI inference\",\n \"url\": \"https://featherless.ai/\",\n \"key_filename\": \"featherless\",\n \"env_vars\": [\"FEATHERLESS_API_KEY\"],\n },\n \"cohere\": {\n \"description\": \"Cohere API\",\n \"url\": \"https://dashboard.cohere.com/api-keys\",\n \"key_filename\": \"cohere\",\n \"env_vars\": [\"COHERE_API_KEY\"],\n },\n \"perplexity\": {\n \"description\": \"Perplexity search API\",\n \"url\": \"https://www.perplexity.ai/settings/api\",\n \"key_filename\": \"perplexity\",\n \"env_vars\": [\"PERPLEXITY_API_KEY\"],\n },\n \"github\": {\n \"description\": \"GitHub personal access tokens\",\n \"url\": \"https://github.com/settings/tokens\",\n \"key_filename\": \"github\",\n \"env_vars\": [\"GITHUB_TOKEN\", \"GH_TOKEN\"],\n },\n \"huggingface\": {\n \"description\": \"Hugging Face Hub tokens\",\n \"url\": \"https://huggingface.co/settings/tokens\",\n \"key_filename\": \"huggingface\",\n # HUGGINGFACE_HUB_TOKEN first so the derived display name reads\n # \"Huggingface\" (not the awkward \"Hf\" form of HF_TOKEN).\n \"env_vars\": [\"HUGGINGFACE_HUB_TOKEN\", \"HF_TOKEN\"],\n },\n}\n"}}}} |