feat(tools): add getToolExplanation() method with XML examples for LLM tool calling
Each tool now provides comprehensive documentation including parameter schemas and concrete <tool_call> XML examples. This helps smaller LLMs understand the exact format required for tool invocation.
This commit is contained in:
@@ -176,6 +176,59 @@ export class BrowserTool extends BaseToolWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public getToolExplanation(): string {
|
||||
return `## Tool: browser
|
||||
Interact with web pages - take screenshots, generate PDFs, and execute JavaScript on pages.
|
||||
|
||||
### Actions:
|
||||
|
||||
**screenshot** - Take a screenshot of a webpage
|
||||
Parameters:
|
||||
- url (required): URL of the page to screenshot
|
||||
|
||||
Example:
|
||||
<tool_call>
|
||||
<tool>browser</tool>
|
||||
<action>screenshot</action>
|
||||
<params>{"url": "https://example.com"}</params>
|
||||
</tool_call>
|
||||
|
||||
**pdf** - Generate a PDF from a webpage
|
||||
Parameters:
|
||||
- url (required): URL of the page to convert to PDF
|
||||
|
||||
Example:
|
||||
<tool_call>
|
||||
<tool>browser</tool>
|
||||
<action>pdf</action>
|
||||
<params>{"url": "https://example.com/report"}</params>
|
||||
</tool_call>
|
||||
|
||||
**evaluate** - Execute JavaScript code on a webpage and return the result
|
||||
Parameters:
|
||||
- url (required): URL of the page to run the script on
|
||||
- script (required): JavaScript code to execute (must return a value)
|
||||
|
||||
Example:
|
||||
<tool_call>
|
||||
<tool>browser</tool>
|
||||
<action>evaluate</action>
|
||||
<params>{"url": "https://example.com", "script": "document.querySelectorAll('a').length"}</params>
|
||||
</tool_call>
|
||||
|
||||
**getPageContent** - Get the text content and title of a webpage
|
||||
Parameters:
|
||||
- url (required): URL of the page to get content from
|
||||
|
||||
Example:
|
||||
<tool_call>
|
||||
<tool>browser</tool>
|
||||
<action>getPageContent</action>
|
||||
<params>{"url": "https://example.com"}</params>
|
||||
</tool_call>
|
||||
`;
|
||||
}
|
||||
|
||||
public getCallSummary(action: string, params: Record<string, unknown>): string {
|
||||
switch (action) {
|
||||
case 'screenshot':
|
||||
|
||||
Reference in New Issue
Block a user