🛂 refactor: Avoid Default Tavily Safe Search (#12939)

This commit is contained in:
Danny Avila 2026-05-03 23:01:23 -04:00 committed by GitHub
parent 3da1d8c961
commit 2c4a78094a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View file

@ -651,7 +651,7 @@ endpoints:
# # includeImages: true # Include images in results
# # includeFavicon: true # Include favicon URL for each result
# # chunksPerSource: 3 # Chunks per source, only with 'advanced' depth (1-3)
# # safeSearch: false # Override Tavily safe search filtering
# # safeSearch: false # Override Tavily safe_search filtering (true is enterprise-only)
# # includeDomains: # Restrict search to specific domains (max 300)
# # - 'example.com'
# # - 'docs.example.com'

View file

@ -129,6 +129,7 @@ describe('web.ts', () => {
expect(result.authResult).toHaveProperty('searchProvider', 'serper');
expect(result.authResult).toHaveProperty('scraperProvider', 'firecrawl');
expect(['jina', 'cohere']).toContain(result.authResult.rerankerType as string);
expect(result.authResult.safeSearch).toBe(SafeSearchTypes.MODERATE);
});
it('should return authenticated=false when a required category is not authenticated', async () => {
@ -774,6 +775,7 @@ describe('web.ts', () => {
expect(result.authResult.tavilyApiKey).toBe('tavily-api-key');
expect(result.authResult.tavilySearchUrl).toBe('https://api.tavily.com/search');
expect(result.authResult.tavilySearchOptions).toEqual(webSearchConfig.tavilySearchOptions);
expect(result.authResult.safeSearch).toBeUndefined();
});
it('should fail authentication when Tavily search API key is missing', async () => {

View file

@ -2,14 +2,14 @@ import {
AuthType,
SafeSearchTypes,
SearchCategories,
SearchProviders,
ScraperProviders,
extractVariableName,
} from 'librechat-data-provider';
import { webSearchAuth } from '@librechat/data-schemas';
import type {
RerankerTypes,
TCustomConfig,
SearchProviders,
ScraperProviders,
TWebSearchConfig,
} from 'librechat-data-provider';
import type { TWebSearchKeys, TWebSearchCategories } from '@librechat/data-schemas';
@ -248,15 +248,18 @@ export async function loadWebSearchAuth({
}
const scraperProvider =
authResult.scraperProvider ?? webSearchConfig?.scraperProvider ?? 'firecrawl';
authResult.scraperProvider ?? webSearchConfig?.scraperProvider ?? ScraperProviders.FIRECRAWL;
let scraperOptionsTimeout: number | undefined;
if (scraperProvider === 'tavily') {
if (scraperProvider === ScraperProviders.TAVILY) {
scraperOptionsTimeout = webSearchConfig?.tavilyScraperOptions?.timeout;
} else if (scraperProvider === 'firecrawl') {
} else if (scraperProvider === ScraperProviders.FIRECRAWL) {
scraperOptionsTimeout = webSearchConfig?.firecrawlOptions?.timeout;
}
authResult.safeSearch = webSearchConfig?.safeSearch ?? SafeSearchTypes.MODERATE;
const searchProvider = authResult.searchProvider ?? webSearchConfig?.searchProvider;
if (searchProvider !== SearchProviders.TAVILY) {
authResult.safeSearch = webSearchConfig?.safeSearch ?? SafeSearchTypes.MODERATE;
}
authResult.scraperTimeout = webSearchConfig?.scraperTimeout ?? scraperOptionsTimeout ?? 7500;
authResult.firecrawlOptions = webSearchConfig?.firecrawlOptions;
authResult.tavilySearchOptions = webSearchConfig?.tavilySearchOptions;