diff --git a/src/renderer/src/aiCore/legacy/clients/openai/OpenAIApiClient.ts b/src/renderer/src/aiCore/legacy/clients/openai/OpenAIApiClient.ts index d839da8964..bed1169144 100644 --- a/src/renderer/src/aiCore/legacy/clients/openai/OpenAIApiClient.ts +++ b/src/renderer/src/aiCore/legacy/clients/openai/OpenAIApiClient.ts @@ -809,6 +809,17 @@ export class OpenAIAPIClient extends OpenAIBaseClient< } } + // Baidu Cloud web search + // @ts-ignore - search_results may not be in standard type definitions + if (context.provider?.id === 'baidu-cloud' && chunk.search_results && chunk.search_results.length > 0) { + hasBeenCollectedWebSearch = true + return { + // @ts-ignore - search_results may not be in standard type definitions + results: chunk.search_results, + source: WebSearchSource.BAIDU_CLOUD + } + } + // TODO: 放到AnthropicApiClient中 // // Other providers... // // @ts-ignore - web_search may not be in standard type definitions diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 197d217793..5b79d3ce77 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -661,6 +661,7 @@ export enum WebSearchSource { QWEN = 'qwen', HUNYUAN = 'hunyuan', ZHIPU = 'zhipu', + BAIDU_CLOUD = 'baidu-cloud', GROK = 'grok', AISDK = 'ai-sdk' } diff --git a/src/renderer/src/utils/citation.ts b/src/renderer/src/utils/citation.ts index 8c97cbcde5..c4231c72c7 100644 --- a/src/renderer/src/utils/citation.ts +++ b/src/renderer/src/utils/citation.ts @@ -155,6 +155,24 @@ export function normalizeCitationMarks( } break } + case WebSearchSource.BAIDU_CLOUD: { + // 百度云格式: ^[1][4]^ → [cite:1], [cite:4] + applyReplacements(/\^\[(\d+(?:\]\[?\d+)*)\]\^/g, (match) => { + const citationNums = match[1] + .replace(/^\[/, '') + .replace(/\]$/g, '') + .split('][') + .map((num) => parseInt(num, 10)) + + const citations = citationNums + .filter((num) => citationMap.has(num)) + .map((num) => `[cite:${num}]`) + .join('') + + return citations + }) + break + } default: { // 简单数字格式: [N] → [cite:N] applyReplacements(/\[(\d+)\]/g, (match) => {