Skip to content

Conversation

sharananurag998
Copy link
Collaborator

No description provided.

I've successfully implemented a web search tool for your JAF framework with the following features:

### Created Files:

1. **`src/adk/tools/webSearchTool.ts`** - Main web search tool implementation with:
   - Support for multiple search providers (Tavily and Bing)
   - Configurable via environment variables (`SEARCH_API_KEY` and `SEARCH_PROVIDER`)
   - Options for regional search, language filtering, safe search, and result limits
   - Returns structured results with title, URL, snippet, and relevance score

2. **`examples/web_search.ts`** - Comprehensive example demonstrating:
   - Direct tool execution for "latest RBI UPI guidelines" query
   - Regional search with India-specific results
   - Multiple provider support (switching between Tavily and Bing)
   - Error handling with helpful setup instructions

### Key Features:

- **Provider Abstraction**: Clean interface for search providers, making it easy to add new ones
- **Environment Configuration**: Reads API keys from `process.env.SEARCH_API_KEY`
- **Structured Results**: Returns array of `{title, url, snippet, relevanceScore?}`
- **Flexible Options**: Support for max results, region, language, and safe search filtering
- **JAF Integration**: Follows the framework's functional patterns using `createFunctionTool`

### Usage:

```typescript
const webSearchTool = createWebSearchTool();
const result = await webSearchTool.execute(
  { query: "latest RBI UPI guidelines", maxResults: 3 },
  context
);
```

The tool is ready to use. Set the `SEARCH_API_KEY` environment variable with your Tavily or Bing API key to enable web search functionality.
Created a **core web search tool** in `src/tools/webSearchTool.ts` that:

1. **Follows JAF core Tool interface** - Uses the proper `Tool<A, Ctx>` type with zod schemas
2. **Multi-provider support** - Tavily and Bing search providers
3. **Environment configuration** - Reads from `SEARCH_API_KEY` and `SEARCH_PROVIDER`
4. **Returns structured data** - `{title, url, snippet, relevanceScore?}` array
5. **Uses ToolResponse** - Proper success/error handling with core ToolResponse class

The tool is ready to use in agents:

```typescript
import { webSearchTool } from './src/tools/webSearchTool';

const agent = createAgent({
  tools: [webSearchTool],
  // ...
});
```

Example at `examples/web_search.ts` shows all features including regional search and provider switching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants