Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client/src/components/SidePanel/Agents/Search/ApiKeyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ export default function ApiKeyDialog({
},
},
},
{
key: ScraperProviders.CRAWL4AI,
label: localize('com_ui_web_search_provider_crawl4ai'),
inputs: {
crawl4aiApiUrl: {
placeholder: localize('com_ui_web_search_crawl4ai_instance_url'),
type: 'text' as const,
},
crawl4aiApiKey: {
placeholder: localize('com_ui_web_search_crawl4ai_api_key'),
type: 'password' as const,
},
},
},
];

const [dropdownOpen, setDropdownOpen] = useState({
Expand Down
4 changes: 4 additions & 0 deletions client/src/hooks/Plugins/useAuthSearchTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type SearchApiKeyFormData = {
firecrawlApiUrl: string;
jinaApiKey: string;
jinaApiUrl: string;
crawl4aiApiUrl: string;
crawl4aiApiKey: string;
cohereApiKey: string;
};

Expand Down Expand Up @@ -56,6 +58,8 @@ const useAuthSearchTool = (options?: { isEntityTool: boolean }) => {
firecrawlApiUrl: data.firecrawlApiUrl,
jinaApiKey: data.jinaApiKey,
jinaApiUrl: data.jinaApiUrl,
crawl4aiApiUrl: data.crawl4aiApiUrl,
crawl4aiApiKey: data.crawl4aiApiKey,
cohereApiKey: data.cohereApiKey,
}).reduce(
(acc, [key, value]) => {
Expand Down
3 changes: 3 additions & 0 deletions client/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@
"com_ui_web_search_provider": "Search Provider",
"com_ui_web_search_provider_searxng": "SearXNG",
"com_ui_web_search_provider_serper": "Serper API",
"com_ui_web_search_provider_crawl4ai": "Crawl4AI API",
"com_ui_web_search_provider_serper_key": "Get your Serper API key",
"com_ui_web_search_reading": "Reading results",
"com_ui_web_search_reranker": "Reranker",
Expand All @@ -1444,6 +1445,8 @@
"com_ui_web_search_scraper_serper_key": "Get your Serper API key",
"com_ui_web_search_searxng_api_key": "Enter SearXNG API Key (optional)",
"com_ui_web_search_searxng_instance_url": "SearXNG Instance URL",
"com_ui_web_search_crawl4ai_api_key": "Enter Crawl4AI API Key (optional)",
"com_ui_web_search_crawl4ai_instance_url": "Crawl4AI Instance URL",
"com_ui_web_searching": "Searching the web",
"com_ui_web_searching_again": "Searching the web again",
"com_ui_weekend_morning": "Happy weekend",
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/app/AppService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ describe('AppService', () => {
firecrawlApiKey: '${FIRECRAWL_API_KEY}',
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
searxngInstanceUrl: '${SEARXNG_INSTANCE_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
}),
memory: undefined,
endpoints: expect.objectContaining({
Expand Down
36 changes: 36 additions & 0 deletions packages/api/src/web/web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
};
Expand Down Expand Up @@ -304,6 +306,8 @@ describe('web.ts', () => {
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
cohereApiKey: '${COHERE_API_KEY}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
};

Expand Down Expand Up @@ -355,6 +359,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
// Specify which services to use
Expand Down Expand Up @@ -449,6 +455,8 @@ describe('web.ts', () => {
jinaApiKey: '${CUSTOM_JINA_KEY}',
jinaApiUrl: '${CUSTOM_JINA_URL}',
cohereApiKey: '${CUSTOM_COHERE_KEY}',
crawl4aiApiUrl: '${CUSTOM_CRAWL4AI_URL}',
crawl4aiApiKey: '${CUSTOM_CRAWL4AI_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
// Specify which services to use
searchProvider: 'serper' as SearchProviders,
Expand Down Expand Up @@ -519,6 +527,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
};
Expand Down Expand Up @@ -581,6 +591,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
};
Expand Down Expand Up @@ -691,6 +703,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
searchProvider: 'serper' as SearchProviders,
Expand Down Expand Up @@ -732,6 +746,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
scraperProvider: 'firecrawl' as ScraperProviders,
Expand Down Expand Up @@ -773,6 +789,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
rerankerType: 'jina' as RerankerTypes,
Expand Down Expand Up @@ -820,6 +838,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
searchProvider: 'invalid-provider' as SearchProviders,
Expand Down Expand Up @@ -855,6 +875,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
rerankerType: 'jina' as RerankerTypes,
Expand Down Expand Up @@ -906,6 +928,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
};
Expand Down Expand Up @@ -947,6 +971,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
firecrawlOptions: {
Expand Down Expand Up @@ -1007,6 +1033,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
scraperTimeout: 15000, // This should take priority
firecrawlOptions: {
Expand Down Expand Up @@ -1049,6 +1077,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
firecrawlOptions: {
includeTags: ['p'],
Expand Down Expand Up @@ -1088,6 +1118,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
firecrawlOptions: {
timeout: 12000, // Only timeout provided
Expand Down Expand Up @@ -1125,6 +1157,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
firecrawlOptions: {
formats: ['html', 'markdown'], // Only formats provided
Expand Down Expand Up @@ -1162,6 +1196,8 @@ describe('web.ts', () => {
firecrawlApiUrl: '${FIRECRAWL_API_URL}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
firecrawlOptions: {
timeout: 8000,
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/web/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ export async function loadWebSearchAuth({
}
}

if (requiredKeys.length === 0) continue;
// If there are no required keys and no optional keys, skip this service
if (requiredKeys.length === 0 && optionalKeys.length === 0) continue;

const requiredAuthFields = extractWebSearchEnvVars({
keys: requiredKeys,
Expand Down
11 changes: 11 additions & 0 deletions packages/data-provider/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ export enum SearchProviders {
export enum ScraperProviders {
FIRECRAWL = 'firecrawl',
SERPER = 'serper',
CRAWL4AI = 'crawl4ai',
}

export enum RerankerTypes {
Expand All @@ -833,6 +834,8 @@ export const webSearchSchema = z.object({
firecrawlApiKey: z.string().optional().default('${FIRECRAWL_API_KEY}'),
firecrawlApiUrl: z.string().optional().default('${FIRECRAWL_API_URL}'),
firecrawlVersion: z.string().optional().default('${FIRECRAWL_VERSION}'),
crawl4aiApiKey: z.string().optional().default('${CRAWL4AI_API_KEY}'),
crawl4aiApiUrl: z.string().optional().default('${CRAWL4AI_API_URL}'),
jinaApiKey: z.string().optional().default('${JINA_API_KEY}'),
jinaApiUrl: z.string().optional().default('${JINA_API_URL}'),
cohereApiKey: z.string().optional().default('${COHERE_API_KEY}'),
Expand Down Expand Up @@ -874,6 +877,14 @@ export const webSearchSchema = z.object({
.optional(),
})
.optional(),
crawl4aiOptions: z
.object({
extractionStrategy: z.string().optional(),
chunkingStrategy: z.string().optional(),
timeout: z.number().optional(),
fitStrategy: z.string().optional()
})
.optional(),
});

export type TWebSearchConfig = DeepPartial<z.infer<typeof webSearchSchema>>;
Expand Down
5 changes: 5 additions & 0 deletions packages/data-schemas/src/app/web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ describe('loadWebSearchConfig', () => {
firecrawlVersion: '${FIRECRAWL_VERSION}',
jinaApiKey: '${JINA_API_KEY}',
jinaApiUrl: '${JINA_API_URL}',
crawl4aiApiUrl: '${CRAWL4AI_API_URL}',
crawl4aiApiKey: '${CRAWL4AI_API_KEY}',
cohereApiKey: '${COHERE_API_KEY}',
safeSearch: SafeSearchTypes.MODERATE,
});
Expand Down Expand Up @@ -154,20 +156,23 @@ describe('loadWebSearchConfig', () => {
expect(result?.searxngInstanceUrl).toBe('${SEARXNG_INSTANCE_URL}');
expect(result?.firecrawlApiUrl).toBe('${FIRECRAWL_API_URL}');
expect(result?.jinaApiUrl).toBe('${JINA_API_URL}');
expect(result?.crawl4aiApiUrl).toBe('${CRAWL4AI_API_URL}');
});

it('should preserve custom URLs', () => {
const config: TCustomConfig['webSearch'] = {
searxngInstanceUrl: 'https://custom-searxng.com',
firecrawlApiUrl: 'https://custom-firecrawl.com',
jinaApiUrl: 'https://custom-jina.com',
crawl4aiApiUrl: 'https://custom-crawl4ai.com'
};

const result = loadWebSearchConfig(config);

expect(result?.searxngInstanceUrl).toBe('https://custom-searxng.com');
expect(result?.firecrawlApiUrl).toBe('https://custom-firecrawl.com');
expect(result?.jinaApiUrl).toBe('https://custom-jina.com');
expect(result?.crawl4aiApiUrl).toBe('https://custom-crawl4ai.com');
});
});
});
10 changes: 10 additions & 0 deletions packages/data-schemas/src/app/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export const webSearchAuth = {
serper: {
serperApiKey: 1 as const,
},
crawl4ai: {
/** Optional (0) - works without API key for public deployments */
crawl4aiApiKey: 0 as const,
/** Optional (0) */
crawl4aiApiUrl: 1 as const,
},
},
rerankers: {
jina: {
Expand Down Expand Up @@ -69,6 +75,8 @@ export function loadWebSearchConfig(
const firecrawlApiKey = config?.firecrawlApiKey ?? '${FIRECRAWL_API_KEY}';
const firecrawlApiUrl = config?.firecrawlApiUrl ?? '${FIRECRAWL_API_URL}';
const firecrawlVersion = config?.firecrawlVersion ?? '${FIRECRAWL_VERSION}';
const crawl4aiApiKey = config?.crawl4aiApiKey ?? '${CRAWL4AI_API_KEY}';
const crawl4aiApiUrl = config?.crawl4aiApiUrl ?? '${CRAWL4AI_API_URL}';
const jinaApiKey = config?.jinaApiKey ?? '${JINA_API_KEY}';
const jinaApiUrl = config?.jinaApiUrl ?? '${JINA_API_URL}';
const cohereApiKey = config?.cohereApiKey ?? '${COHERE_API_KEY}';
Expand All @@ -85,6 +93,8 @@ export function loadWebSearchConfig(
firecrawlApiKey,
firecrawlApiUrl,
firecrawlVersion,
crawl4aiApiKey,
crawl4aiApiUrl,
searxngInstanceUrl,
};
}
2 changes: 2 additions & 0 deletions packages/data-schemas/src/types/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type TWebSearchKeys =
| 'firecrawlApiKey'
| 'firecrawlApiUrl'
| 'firecrawlVersion'
| 'crawl4aiApiKey'
| 'crawl4aiApiUrl'
| 'jinaApiKey'
| 'jinaApiUrl'
| 'cohereApiKey';
Expand Down