mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat: add routed online search providers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user