feat: add routed online search providers

This commit is contained in:
云服务部-叶林立
2026-08-19 11:04:03 +08:00
parent bf8bb42a09
commit 5a85660b5d
12 changed files with 500 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
const TAVILY_TOOL_PREFIX = "tavily_";
export type TavilyToolDefinition = {
name: string;
label: string;
description: string;
promptSnippet?: string;
promptGuidelines?: string[];
[key: string]: unknown;
};
function rewriteToolReferences(text: string): string {
return text.replace(/\bweb_search\b/g, "tavily_web_search").replace(/\bweb_fetch\b/g, "tavily_web_fetch");
}
export function prefixTavilyTool<T extends TavilyToolDefinition>(definition: T): T {
return {
...definition,
name: `${TAVILY_TOOL_PREFIX}${definition.name}`,
label: definition.label.startsWith("Tavily ") ? definition.label : `Tavily ${definition.label}`,
description: rewriteToolReferences(definition.description),
promptSnippet: definition.promptSnippet ? rewriteToolReferences(definition.promptSnippet) : undefined,
promptGuidelines: definition.promptGuidelines?.map(rewriteToolReferences),
} as T;
}