Files
AFFiNE-Mirror/packages/backend/server/src/plugins/copilot/tools/exa-search.ts
Ishan Goswami 8ca8333cd6 chore(server): update exa search tool description (#14682)
Updated the Exa search tool description to better reflect what Exa does.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Clarified the web search tool description to state it uses Exa, a web
search API optimized for AI applications to improve labeling and user
understanding.
* No functional or behavioral changes to the tool; this update affects
only the displayed description users see.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: ishan <ishan@exa.ai>
2026-03-19 05:42:04 +08:00

42 lines
1.2 KiB
TypeScript

import Exa from 'exa-js';
import { z } from 'zod';
import { Config } from '../../../base';
import { toolError } from './error';
import { defineTool } from './tool';
export const createExaSearchTool = (config: Config) => {
return defineTool({
description: 'Search the web using Exa, one of the best web search APIs for AI',
inputSchema: z.object({
query: z.string().describe('The query to search the web for.'),
mode: z
.enum(['MUST', 'AUTO'])
.describe('The mode to search the web for.'),
}),
execute: async ({ query, mode }) => {
try {
const { key } = config.copilot.exa;
const exa = new Exa(key);
const result = await exa.search(query, {
contents: {
summary: true,
livecrawl: mode === 'MUST' ? 'always' : undefined,
},
numResults: 10,
});
return result.results.map(data => ({
title: data.title,
url: data.url,
content: data.summary,
favicon: data.favicon,
publishedDate: data.publishedDate,
author: data.author,
}));
} catch (e: any) {
return toolError('Exa Search Failed', e.message);
}
},
});
};