-
Notifications
You must be signed in to change notification settings - Fork 53
feat: integrated DDGS search tool and refactored handlers #106
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
Conversation
WalkthroughThe changes migrate the backend web search functionality from Tavily Search to DuckDuckGo Search. This includes updating import paths, tool instantiations, and result processing logic to use the new DuckDuckGo search tool. A new dependency on the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DevRelAgent
participant DuckDuckGoSearchTool
participant DDGS Library
User->>DevRelAgent: Initiate web search query
DevRelAgent->>DuckDuckGoSearchTool: search(query)
DuckDuckGoSearchTool->>DDGS Library: Perform DuckDuckGo search
DDGS Library-->>DuckDuckGoSearchTool: Return search results
DuckDuckGoSearchTool-->>DevRelAgent: Return processed results
DevRelAgent-->>User: Return search results
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
backend/app/agents/devrel/tools/search_tool/ddg.py (1)
15-17
: Consider enhancing the helper method for better error isolation.While the current implementation works, consider adding error handling directly in the helper method to better isolate DDGS-specific exceptions.
def _perform_search(self, query: str, max_results: int): - with DDGS() as ddg: - return ddg.text(query, max_results=max_results) + try: + with DDGS() as ddg: + return ddg.text(query, max_results=max_results) + except Exception as e: + logger.debug("DDGS library error: %s", str(e)) + raise
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
poetry.lock
is excluded by!**/*.lock
📒 Files selected for processing (6)
backend/app/agents/devrel/agent.py
(2 hunks)backend/app/agents/devrel/github/tools/search.py
(1 hunks)backend/app/agents/devrel/nodes/handlers/web_search.py
(2 hunks)backend/app/agents/devrel/tools/search_tool/ddg.py
(1 hunks)backend/app/agents/devrel/tools/search_tool/tavilly.py
(1 hunks)pyproject.toml
(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
backend/app/agents/devrel/nodes/handlers/web_search.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
backend/app/agents/devrel/tools/search_tool/tavilly.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
backend/app/agents/devrel/agent.py (3)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#75
File: backend/app/agents/devrel/agent.py:34-35
Timestamp: 2025-06-13T21:56:19.183Z
Learning: In the Devr.AI backend, the DevRelAgent follows a singleton pattern where only one instance exists for the entire application lifetime, using InMemorySaver with thread-based conversation management to persist user conversations across sessions.
backend/app/agents/devrel/github/tools/search.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
backend/app/agents/devrel/tools/search_tool/ddg.py (2)
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method has partial error handling for missing API key, AttributeError, ConnectionError, and TimeoutError, but lacks a comprehensive Exception catch-all block, so calling functions may still need additional error handling for other potential exceptions.
Learnt from: smokeyScraper
PR: AOSSIE-Org/Devr.AI#72
File: backend/app/agents/devrel/nodes/handle_web_search_node.py:31-42
Timestamp: 2025-06-08T13:31:11.572Z
Learning: In backend/app/agents/devrel/tools/search_tool.py, the TavilySearchTool.search() method already includes comprehensive error handling that catches all exceptions and returns an empty list instead of raising them, so calling functions don't need additional try-catch blocks.
🧬 Code Graph Analysis (3)
backend/app/agents/devrel/agent.py (1)
backend/app/agents/devrel/tools/search_tool/ddg.py (1)
DuckDuckGoSearchTool
(9-42)
backend/app/agents/devrel/github/tools/search.py (1)
backend/app/agents/devrel/tools/search_tool/ddg.py (1)
DuckDuckGoSearchTool
(9-42)
backend/app/agents/devrel/tools/search_tool/ddg.py (1)
backend/app/agents/devrel/tools/search_tool/tavilly.py (1)
search
(17-52)
🔇 Additional comments (10)
pyproject.toml (1)
27-27
: LGTM! Dependency addition is appropriate.The version constraint for the ddgs package follows best practices, allowing patch and minor updates while preventing potentially breaking changes in major version 10.
backend/app/agents/devrel/tools/search_tool/tavilly.py (1)
52-52
: LGTM! Minor formatting cleanup.Removing the trailing newline improves code consistency.
backend/app/agents/devrel/nodes/handlers/web_search.py (2)
44-46
: LGTM! Source identifier updates are consistent.The changes correctly update the source identifiers from "tavily_search" to "duckduckgo_search" to reflect the new search tool being used.
60-62
: LGTM! Field mapping updated correctly.The change from
'snippet'
to'content'
aligns with the DuckDuckGoSearchTool's result format, which returns content in the 'content' field rather than 'snippet'.backend/app/agents/devrel/agent.py (2)
30-30
: LGTM! Search tool instantiation updated correctly.The instantiation is updated to use DuckDuckGoSearchTool, maintaining the same interface as the previous TavilySearchTool.
8-8
: Import Verified: DuckDuckGoSearchTool Implementation ExistsConfirmed that
backend/app/agents/devrel/tools/search_tool/ddg.py
definesclass DuckDuckGoSearchTool
on line 9. The import and instantiation changes are correct.backend/app/agents/devrel/github/tools/search.py (3)
3-3
: LGTM! Import updated correctly.The import correctly references the new DuckDuckGoSearchTool from the updated module path.
8-8
: LGTM! Docstring updated appropriately.The docstring correctly reflects the change to using the DuckDuckGo search tool.
12-12
: LGTM! Search tool instantiation updated correctly.The instantiation correctly uses DuckDuckGoSearchTool, which based on the retrieved learnings should have improved error handling compared to the previous TavilySearchTool.
backend/app/agents/devrel/tools/search_tool/ddg.py (1)
19-42
: The DDG search’s error‐handling branch for network issues never returns a value (falls through to None), and we can’t confirm “body”/“href”/“title” without docs or a quick test. To be safe:• In the
except (ConnectionError, TimeoutError)
block addreturn []
so it always returns a list
• Run a brief smoke test against DDGS or check its docs to confirm the result dict has “results” → list of{ title, body, href }
.Please update accordingly or verify with a test call to DDGS.
very well aligned and clean work @Rudra775! Also, how were you initializing the app? I'm facing a few import path errors, which are preventing the app from starting. Could you please check once again, or lmk how you were using it. The current app is set to run under PS: In order to have a clean commit history, please undo your last commit and make changes within that, then make a commit with a force push. This keeps the commit history clean. I'm preferring "'n' commits for edits" + "1 commit for coderabbit fix" (Easiest is to use editor's (VS Code/Cursor) GitHub section for this) |
merged! |
🎯 Overview
Closes #82
📝 Description
This pull request replaces Tavily web search integration with a free and open-source alternative: DuckDuckGo, using the ddgs package. It updates the
search_tool.py
logic to query using DuckDuckGo and append source URLs as citations in the final LLM response.🔧 Changes Made
Created:
backend/app/agents/devrel/tools/search_tool/ddg.py
Moved: Tavily logic to
backend/app/agents/devrel/tools/search_tool/tavily.py
Modified:
backend/app/agents/devrel/nodes/agent.py
📷 Screenshots or Visual Changes (if applicable)
Summary by CodeRabbit
New Features
Bug Fixes
Chores