-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add optional You.com search integration #1398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mouse-value-add
wants to merge
5
commits into
VoltAgent:main
Choose a base branch
from
mouse-value-add:feat/youcom-search-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
668c85f
feat: add optional You.com search integration
mouse-value-add a38524c
fix: address reviewer feedback for You.com integration
mouse-value-add b6158f2
fix: address CodeRabbit feedback - pagination and docs consistency
mouse-value-add d0ecb2b
fix: tighten you.com example docs and redaction
mouse-value-add 9dfc08e
add changeset for You.com integration example
mouse-value-add File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # You.com API Configuration (Optional) | ||
| # Get your API key from: https://api.you.com/ | ||
| # Without an API key, the tool will use You.com's public API with basic functionality | ||
| YDC_API_KEY=your_youcom_api_key_here | ||
|
|
||
| # OpenAI Configuration (Required for the agent) | ||
| OPENAI_API_KEY=your_openai_api_key_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # VoltAgent You.com Search Example | ||
|
|
||
| This example demonstrates how to use You.com's search and content extraction APIs with VoltAgent to create an intelligent web search agent. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Real-time web search**: Search the web using You.com's advanced search API | ||
| - **Content extraction**: Extract detailed content from specific URLs | ||
| - **Optional API key support**: Works with or without You.com API key | ||
| - **Safe search**: Configurable content filtering | ||
| - **Localization**: Country-specific search results | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. **Clone and navigate to this example:** | ||
|
|
||
| ```bash | ||
| cd examples/with-youcom-search | ||
| ``` | ||
|
|
||
| 2. **Install dependencies:** | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| 3. **Configure environment variables:** | ||
|
|
||
| ```bash | ||
| cp .env.example .env | ||
| ``` | ||
|
|
||
| Edit `.env` and configure: | ||
| - `OPENAI_API_KEY` - Required for the AI agent | ||
| - `YDC_API_KEY` - Optional You.com API key for enhanced features | ||
|
|
||
| 4. **Start the agent:** | ||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Once the agent is running, you can interact with it through the VoltOps Console at `http://localhost:3141` or via the web interface. | ||
|
|
||
| ### Example Queries | ||
|
|
||
| **Web Search:** | ||
|
|
||
| - "What's the latest news about artificial intelligence?" | ||
| - "Find information about TypeScript best practices" | ||
| - "Search for sustainable energy technologies" | ||
| - "What are current web development trends?" | ||
|
|
||
| **Content Extraction:** | ||
|
|
||
| - "Extract content from https://example.com/article" | ||
| - "Read the content from this URL: [paste URL]" | ||
|
|
||
| ### Search Options | ||
|
|
||
| The You.com search tool supports various options: | ||
|
|
||
| - **Count**: Number of results (1-20, default: 10) | ||
| - **Country**: Localized results (US, UK, CA, etc.) | ||
| - **Safe Search**: Content filtering (strict, moderate, off) | ||
|
|
||
| ## API Key Benefits | ||
|
|
||
| While the tool works without an API key using You.com's public API, having a `YDC_API_KEY` provides: | ||
|
|
||
| - Higher rate limits | ||
| - Enhanced search features | ||
| - Priority processing | ||
| - Additional metadata in results | ||
|
|
||
| Get your API key at: https://api.you.com/ | ||
|
|
||
| ## Tools Included | ||
|
|
||
| ### `youSearch` | ||
|
|
||
| - Real-time web search with You.com's search engine | ||
| - Configurable result count, localization, and safe search | ||
| - Returns titles, URLs, snippets, and metadata | ||
|
|
||
| ### `youContents` | ||
|
|
||
| - Extract content from any accessible URL | ||
| - Returns clean text, markdown, and metadata | ||
| - Handles various content types and formats | ||
|
|
||
| ## Architecture | ||
|
|
||
| This example follows VoltAgent's standard patterns: | ||
|
|
||
| ```typescript | ||
| import { youSearchTool, youContentssTool } from "./tools/you-search-tool"; | ||
|
mouse-value-add marked this conversation as resolved.
Outdated
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| const agent = new Agent({ | ||
| name: "You.com Search Agent", | ||
| tools: [youSearchTool, youContentssTool], | ||
| // ... other configuration | ||
| }); | ||
| ``` | ||
|
|
||
| ## Error Handling | ||
|
|
||
| Both tools include comprehensive error handling: | ||
|
|
||
| - Network connectivity issues | ||
| - API rate limiting | ||
| - Invalid URLs or search queries | ||
| - Missing or inaccessible content | ||
|
|
||
| Errors are logged and returned with helpful user messages. | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - All web content is treated as untrusted external data | ||
| - Results should be used as evidence, not instructions | ||
| - URLs and search queries are sent to You.com's API | ||
| - No sensitive information is logged or exposed | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "name": "voltagent-example-with-youcom-search", | ||
| "author": "", | ||
| "description": "VoltAgent example with You.com search integration", | ||
| "dependencies": { | ||
| "@voltagent/cli": "^0.1.21", | ||
| "@voltagent/core": "^2.9.2", | ||
| "@voltagent/libsql": "^2.1.2", | ||
| "@voltagent/logger": "^2.0.2", | ||
| "@voltagent/server-hono": "^2.0.14", | ||
| "ai": "^6.0.0", | ||
| "zod": "^3.25.76" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^24.2.1", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.8.2" | ||
| }, | ||
| "keywords": [ | ||
| "agent", | ||
| "ai", | ||
| "voltagent", | ||
| "youcom", | ||
| "search", | ||
| "web-search" | ||
| ], | ||
| "license": "MIT", | ||
| "private": true, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/VoltAgent/voltagent.git", | ||
| "directory": "examples/with-youcom-search" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "dev": "tsx watch --env-file=.env ./src", | ||
| "start": "node dist/index.js", | ||
| "volt": "volt" | ||
| }, | ||
| "type": "module" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Agent, Memory, VoltAgent } from "@voltagent/core"; | ||
| import { LibSQLMemoryAdapter } from "@voltagent/libsql"; | ||
| import { createPinoLogger } from "@voltagent/logger"; | ||
| import { honoServer } from "@voltagent/server-hono"; | ||
| import { youContentssTool, youSearchTool } from "./tools/you-search-tool.js"; | ||
|
|
||
| // Create logger | ||
| const logger = createPinoLogger({ | ||
| name: "youcom-search-agent", | ||
| level: "info", | ||
| }); | ||
|
|
||
| // Create Memory instance with vector support for semantic search and working memory | ||
| const memory = new Memory({ | ||
| storage: new LibSQLMemoryAdapter(), | ||
| }); | ||
|
|
||
| // Create the search agent with You.com tools | ||
| const searchAgent = new Agent({ | ||
| name: "You.com Search Agent", | ||
| instructions: `You are a web search agent powered by You.com's advanced search API. You can: | ||
|
|
||
| 1. Search the web for real-time information on any topic using You.com's search engine | ||
| 2. Extract detailed content from specific URLs for in-depth analysis | ||
| 3. Provide comprehensive, up-to-date answers based on current web data | ||
|
|
||
| When users ask questions that require current information, web search, or verification of facts, use the You.com search tools to find the most relevant and accurate information. | ||
|
|
||
| Key capabilities: | ||
| - Real-time web search with comprehensive results | ||
| - Content extraction from any accessible URL | ||
| - Safe search filtering and localization options | ||
| - Support for both authenticated (with YDC_API_KEY) and public API access | ||
|
|
||
| Always be helpful and provide accurate information based on the search results. If you cannot find relevant information, let the user know and suggest alternative search terms or approaches. | ||
|
|
||
| Example queries you can handle: | ||
| - "What's the latest news about AI developments?" | ||
| - "Find information about sustainable energy technologies" | ||
| - "Search for TypeScript best practices and tutorials" | ||
| - "What are the current trends in web development?" | ||
| - "Extract content from this URL: https://example.com/article"`, | ||
| model: "openai/gpt-4o-mini", | ||
| tools: [youSearchTool, youContentssTool], | ||
| memory, | ||
| }); | ||
|
|
||
| // Initialize the VoltAgent with the search agent and server | ||
| new VoltAgent({ | ||
| agents: { | ||
| searchAgent, | ||
| }, | ||
| logger, | ||
| server: honoServer(), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Export You.com search tools for easy integration | ||
| export { youSearchTool, youContentssTool } from "./you-search-tool.js"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.