feat(search): add ollama-search and zai-search with credential fallback
Register two web search providers that reuse an existing chat provider's API key instead of requiring their own connection: - ollama-search (POST ollama.com/api/web_search) reuses the `ollama` key - zai-search (POST api.z.ai MCP web_search_prime) reuses the `glm` key A new `credentialFallback` registry field drives this: when a search provider has no connection of its own, the search handler falls back to the linked chat provider's credentials. Also teach getProviderIconSrc to serve .svg logos for providers that ship vector art.
This commit is contained in:
@@ -5,7 +5,7 @@ import { RISK_NOTICE } from "@/shared/constants/providersDisplay";
|
||||
const MEDIA_ENTRY_KEYS = [
|
||||
"serviceKinds", "ttsConfig", "sttConfig", "embeddingConfig",
|
||||
"imageConfig", "imageToTextConfig", "videoConfig", "musicConfig",
|
||||
"searchViaChat", "searchConfig", "fetchConfig",
|
||||
"searchViaChat", "searchConfig", "fetchConfig", "credentialFallback",
|
||||
"modelsFetcher", "mediaPriority", "hiddenKinds",
|
||||
];
|
||||
|
||||
|
||||
@@ -5,8 +5,12 @@ const ICON_ALIASES = {
|
||||
"perplexity-agent": "perplexity",
|
||||
"gitlab-duo": "gitlab",
|
||||
"vercel-ai-gateway": "vercel",
|
||||
"ollama-search": "ollama",
|
||||
};
|
||||
|
||||
// Providers that ship an .svg logo instead of .png.
|
||||
const SVG_PROVIDER_IDS = new Set(["zai-search"]);
|
||||
|
||||
// Runtime only — first 404 remembers id for the whole session
|
||||
const failedIds = new Set();
|
||||
|
||||
@@ -25,10 +29,13 @@ export function resolveProviderIconId(providerId) {
|
||||
return aliased;
|
||||
}
|
||||
|
||||
/** `/providers/{id}.png` or null when previously failed. */
|
||||
/** `/providers/{id}.{png|svg}` or null when previously failed. */
|
||||
export function getProviderIconSrc(providerId) {
|
||||
const id = resolveProviderIconId(providerId);
|
||||
return id ? `/providers/${id}.png` : null;
|
||||
if (!id) return null;
|
||||
// svg for vector logos, png for everything else
|
||||
const ext = SVG_PROVIDER_IDS.has(id) ? "svg" : "png";
|
||||
return `/providers/${id}.${ext}`;
|
||||
}
|
||||
|
||||
/** Call from img onError so later mounts skip the request. */
|
||||
|
||||
Reference in New Issue
Block a user