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:
@@ -148,8 +148,23 @@ async function handleSingleProviderSearch(body, providerInput, request, apiKey,
|
||||
let lastError = null;
|
||||
let lastStatus = null;
|
||||
|
||||
// Credential fallback: some search providers reuse the API key of a related
|
||||
// chat provider (e.g. ollama-search reuses the `ollama` chat key, zai-search
|
||||
// reuses the `glm` chat key). When the search provider has no own connection,
|
||||
// fall back to the linked provider's credentials.
|
||||
const fallbackProviderId = resolvedProvider.credentialFallback;
|
||||
|
||||
while (true) {
|
||||
const credentials = await getProviderCredentials(providerId, excludeConnectionIds);
|
||||
let credentials = await getProviderCredentials(providerId, excludeConnectionIds);
|
||||
|
||||
// Fall back to the related chat provider's credentials when this search
|
||||
// provider has none of its own (one key, chat + search).
|
||||
if (!credentials && fallbackProviderId) {
|
||||
credentials = await getProviderCredentials(fallbackProviderId, excludeConnectionIds);
|
||||
if (credentials) {
|
||||
log.info("AUTH", `\x1b[32m${providerId} reusing ${fallbackProviderId} credentials\x1b[0m`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!credentials || credentials.allRateLimited) {
|
||||
if (credentials?.allRateLimited) {
|
||||
|
||||
Reference in New Issue
Block a user