diff --git a/src/renderer/src/config/models.ts b/src/renderer/src/config/models.ts index 2ade2c1a74..5f82d39d70 100644 --- a/src/renderer/src/config/models.ts +++ b/src/renderer/src/config/models.ts @@ -2570,6 +2570,10 @@ export function isWebSearchModel(model: Model): boolean { return true } + if (provider.id === 'grok') { + return true + } + return false } @@ -2600,6 +2604,16 @@ export function getOpenAIWebSearchParams(assistant: Assistant, model: Model): Re if (assistant.enableWebSearch) { const webSearchTools = getWebSearchTools(model) + if (model.provider === 'grok') { + return { + search_parameters: { + mode: 'auto', + return_citations: true, + sources: [{ type: 'web' }, { type: 'x' }, { type: 'news' }] + } + } + } + if (model.provider === 'hunyuan') { return { enable_enhancement: true, citation: true, search_info: true } } diff --git a/src/renderer/src/providers/AiProvider/OpenAIProvider.ts b/src/renderer/src/providers/AiProvider/OpenAIProvider.ts index 8d27569ee4..3e3a6e432a 100644 --- a/src/renderer/src/providers/AiProvider/OpenAIProvider.ts +++ b/src/renderer/src/providers/AiProvider/OpenAIProvider.ts @@ -777,6 +777,18 @@ export default class OpenAIProvider extends BaseOpenAIProvider { } } as LLMWebSearchCompleteChunk) } + if (assistant.model?.provider === 'grok') { + const citations = originalFinishRawChunk.citations + if (citations) { + onChunk({ + type: ChunkType.LLM_WEB_SEARCH_COMPLETE, + llm_web_search: { + results: citations, + source: WebSearchSource.GROK + } + } as LLMWebSearchCompleteChunk) + } + } if (assistant.model?.provider === 'perplexity') { const citations = originalFinishRawChunk.citations if (citations) { diff --git a/src/renderer/src/store/messageBlock.ts b/src/renderer/src/store/messageBlock.ts index c9cc55cec3..cf9515fe00 100644 --- a/src/renderer/src/store/messageBlock.ts +++ b/src/renderer/src/store/messageBlock.ts @@ -160,6 +160,7 @@ const formatCitationsFromBlock = (block: CitationMessageBlock | undefined): Cita } }) || [] break + case WebSearchSource.GROK: case WebSearchSource.OPENROUTER: case WebSearchSource.PERPLEXITY: formattedCitations = diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index a269d32676..921b846a3f 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -473,7 +473,8 @@ export enum WebSearchSource { PERPLEXITY = 'perplexity', QWEN = 'qwen', HUNYUAN = 'hunyuan', - ZHIPU = 'zhipu' + ZHIPU = 'zhipu', + GROK = 'grok' } export type WebSearchResponse = {