Files
DeepTutor/web/components/common/ProviderIcon.tsx
Bingxi Zhao (Frank) f4f2a73b2a feat(search): rebuild the search provider layer and add six providers
Two pieces of work land together because the second is built on the
first: the provider layer was consolidated onto one spec table, then six
new providers were registered against it.

Layer overhaul
- Converge seven separate provider lists (backend registry, runtime
  config, settings router, CLI wizard, frontend catalog, i18n, tests)
  onto a single SEARCH_PROVIDERS spec table; every consumer derives from
  it instead of keeping its own copy.
- Fix three silent defects: serper's `num` never reached the API (it was
  swallowed by **kwargs, so max_results did nothing), serper dropped its
  proxies, and jina had no result-count limit at all.
- A runtime failure (rate limit, timeout, unreachable network) no longer
  fails the whole turn. The request walks the user's other credentialed
  search profiles and finally DuckDuckGo, recording the downgrade under
  a top-level `search_fallback` key so the trace shows what happened.
- Drop three provider modules that were never registered (exa, baidu,
  openrouter). They stay in the deprecated list, so a stale config reads
  as outdated rather than as a misspelled name.

Six new providers
doubao, bocha, zhipu, firecrawl, qianfan, aliyun_iqs — selectable under
Settings > Catalog > Search with their credential fields derived from the
spec table, and offered by `deeptutor init`. All six set
`soft_fallback=False`: five are China-hosted and the DuckDuckGo fallback
is unreachable on those networks, so a missing API key has to fail
loudly instead of silently timing out somewhere else.

Baidu returns as `qianfan` on the official Qianfan API; the old `baidu`
key stays deprecated.
2026-08-13 16:41:39 +08:00

98 lines
3.6 KiB
TypeScript

import { Bot } from "lucide-react";
/**
* Vendor logos for LLM/embedding providers, keyed by binding name
* (see deeptutor/services/provider_registry.py). SVGs are vendored from
* @lobehub/icons-static-svg (MIT) into /public/provider-icons.
*
* `mono` icons are solid-fill brand marks that render black as <img>;
* they get `dark:invert` so they stay visible on dark backgrounds.
* Unknown/custom bindings fall back to the generic Bot icon.
*/
const PROVIDER_ICONS: Record<string, { file: string; mono?: boolean }> = {
openai: { file: "openai.svg", mono: true },
openai_codex: { file: "openai.svg", mono: true },
anthropic: { file: "anthropic.svg", mono: true },
custom_anthropic: { file: "anthropic.svg", mono: true },
azure_openai: { file: "azure-color.svg" },
openrouter: { file: "openrouter.svg", mono: true },
aihubmix: { file: "aihubmix-color.svg" },
siliconflow: { file: "siliconcloud-color.svg" },
volcengine: { file: "volcengine-color.svg" },
volcengine_coding_plan: { file: "volcengine-color.svg" },
byteplus: { file: "bytedance-color.svg" },
byteplus_coding_plan: { file: "bytedance-color.svg" },
github_copilot: { file: "githubcopilot.svg", mono: true },
deepseek: { file: "deepseek-color.svg" },
gemini: { file: "gemini-color.svg" },
google: { file: "gemini-color.svg" },
zhipu: { file: "zhipu-color.svg" },
dashscope: { file: "qwen-color.svg" },
aliyun: { file: "qwen-color.svg" },
moonshot: { file: "moonshot.svg", mono: true },
minimax: { file: "minimax-color.svg" },
minimax_anthropic: { file: "minimax-color.svg" },
mistral: { file: "mistral-color.svg" },
stepfun: { file: "stepfun-color.svg" },
xiaomi_mimo: { file: "xiaomimimo.svg", mono: true },
vllm: { file: "vllm-color.svg" },
ollama: { file: "ollama.svg", mono: true },
lm_studio: { file: "lmstudio.svg", mono: true },
nvidia_nim: { file: "nvidia-color.svg" },
groq: { file: "groq.svg", mono: true },
qianfan: { file: "baiducloud-color.svg" },
cohere: { file: "cohere-color.svg" },
jina: { file: "jina.svg", mono: true },
// Search providers (see SEARCH_PROVIDERS in
// deeptutor/services/config/provider_runtime.py). brave/duckduckgo/searxng
// come from simple-icons with the brand color baked in. Keys shared with an
// LLM binding above (zhipu, qianfan) already resolve and are not repeated.
// A search provider with no vendored logo falls back to the generic Bot mark
// rather than borrowing an unrelated brand's.
tavily: { file: "tavily-color.svg" },
perplexity: { file: "perplexity-color.svg" },
exa: { file: "exa-color.svg" },
brave: { file: "brave.svg" },
duckduckgo: { file: "duckduckgo.svg" },
searxng: { file: "searxng.svg" },
baidu: { file: "baidu-color.svg" },
// Doubao is Volcengine's own model line, so it carries the Ark mark.
doubao: { file: "volcengine-color.svg" },
aliyun_iqs: { file: "qwen-color.svg" },
};
export default function ProviderIcon({
provider,
size = 13,
className = "",
}: {
provider?: string | null;
size?: number;
className?: string;
}) {
const spec = provider
? PROVIDER_ICONS[provider.trim().toLowerCase()]
: undefined;
if (!spec) {
return (
<Bot
size={size}
strokeWidth={1.7}
className={`shrink-0 ${className}`.trim()}
/>
);
}
return (
// eslint-disable-next-line @next/next/no-img-element
<img
src={`/provider-icons/${spec.file}`}
alt=""
aria-hidden
width={size}
height={size}
draggable={false}
className={`shrink-0 select-none ${spec.mono ? "dark:invert" : ""} ${className}`.trim()}
/>
);
}