fix: max search result (#11883)

* fix: add search result limit

* fix: typo

* Update src/renderer/src/aiCore/utils/websearch.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: test

* Apply suggestion from @GeorgeDong32

Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: George·Dong <98630204+GeorgeDong32@users.noreply.github.com>
This commit is contained in:
SuYao 2025-12-13 22:58:59 +08:00 committed by GitHub
parent f0ec2354dc
commit ee7eee24da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -259,7 +259,7 @@ describe('websearch utils', () => {
expect(result).toEqual({
xai: {
maxSearchResults: 50,
maxSearchResults: 30,
returnCitations: true,
sources: [{ type: 'web', excludedWebsites: [] }, { type: 'news' }, { type: 'x' }],
mode: 'on'

View File

@ -9,6 +9,8 @@ import type { CherryWebSearchConfig } from '@renderer/store/websearch'
import type { Model } from '@renderer/types'
import { mapRegexToPatterns } from '@renderer/utils/blacklistMatchPattern'
const X_AI_MAX_SEARCH_RESULT = 30
export function getWebSearchParams(model: Model): Record<string, any> {
if (model.provider === 'hunyuan') {
return { enable_enhancement: true, citation: true, search_info: true }
@ -82,7 +84,7 @@ export function buildProviderBuiltinWebSearchConfig(
const excludeDomains = mapRegexToPatterns(webSearchConfig.excludeDomains)
return {
xai: {
maxSearchResults: webSearchConfig.maxResults,
maxSearchResults: Math.min(webSearchConfig.maxResults, X_AI_MAX_SEARCH_RESULT),
returnCitations: true,
sources: [
{