-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Added DuckDuckGo Search Tool and Agent in AutoGen Extensions #6682
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4018157
mark1 with example working
varadsrivastava 3e4f7c6
duckduckgo agent mark 2 example updated
varadsrivastava fcbc97e
Update _duckduckgo_agent.py
varadsrivastava b8d8357
Merge branch 'microsoft:main' into main
varadsrivastava 7473bd7
mark 2 updates: final examples added
varadsrivastava d61b4b7
Merge branch 'microsoft:main' into main
varadsrivastava 72fadef
Merge branch 'microsoft:main' into main
varadsrivastava 5da3d8d
Merge branch 'microsoft:main' into main
varadsrivastava e65ef87
added duckduckgo search agent
varadsrivastava 3f42bf6
Merge branch 'main' of https://github.com/varadsrivastava/autogen
varadsrivastava 30b037d
duckduckgo search agent dependency update
varadsrivastava 1d697f3
Updated prompt variables and RST code blocks
varadsrivastava ef7cd84
Merge branch 'main' into main
varadsrivastava e59f215
updated readme and api doc
varadsrivastava 1019f6e
Merge branch 'main' of https://github.com/varadsrivastava/autogen
varadsrivastava d81b398
Added return_value_as_string function
varadsrivastava 0db6540
minor update to return_value_as_string
varadsrivastava d2da914
updated tool path
varadsrivastava 53ed83d
Merge branch 'main' into main
ekzhu 24e3e20
Merge branch 'main' into main
varadsrivastava 4414cba
Merge branch 'main' into main
ekzhu 9c5399a
update deps
ekzhu 97c3460
fix tests
ekzhu 6febb60
update test
ekzhu 07a3eac
add test to increase coverage
ekzhu 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
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
91 changes: 91 additions & 0 deletions
91
python/packages/autogen-ext/src/autogen_ext/agents/duckduckgo_search/_duckduckgo_agent.py
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,91 @@ | ||
| # DuckDuckGo Search Agent created by Varad Srivastava | ||
| from typing import Any, Optional | ||
|
|
||
| from autogen_agentchat.agents import AssistantAgent | ||
| from autogen_core.models import ChatCompletionClient | ||
| from autogen_ext.tools.web_search.duckduckgo._duckduckgo_search import DuckDuckGoSearchTool | ||
|
|
||
|
|
||
| class DuckDuckGoSearchAgent(AssistantAgent): | ||
| """ | ||
| A specialized AssistantAgent that uses DuckDuckGo for web searches. | ||
|
|
||
| This agent is designed to perform web searches using DuckDuckGo and provide | ||
| relevant information based on the search results. It can be used in group chats | ||
| or as a standalone agent for research and information gathering tasks. | ||
|
|
||
| The agent comes pre-configured with a DuckDuckGo search tool and a system message | ||
| optimized for research tasks. | ||
|
|
||
| Example: | ||
| .. code-block:: python | ||
|
|
||
| from autogen_ext.agents.duckduckgo_search import DuckDuckGoSearchAgent | ||
| from autogen_ext.models.openai import OpenAIChatCompletionClient | ||
|
|
||
| # Create a model client | ||
| model_client = OpenAIChatCompletionClient(model="gpt-4") | ||
|
|
||
| # Create a DuckDuckGo search agent | ||
| search_agent = DuckDuckGoSearchAgent( | ||
| name="researcher", | ||
| model_client=model_client, | ||
| ) | ||
|
|
||
| # Use the agent | ||
| result = await search_agent.run(task="What are the latest developments in AI?") | ||
| print(result.messages[-1].content) | ||
| """ | ||
|
|
||
| DEFAULT_DESCRIPTION = "A research assistant that uses DuckDuckGo to find and analyze information from the web." | ||
|
|
||
| DEFAULT_SYSTEM_MESSAGE = """You are a research assistant that uses DuckDuckGo to find accurate information. | ||
|
|
||
| When conducting research: | ||
| 1. Break down complex queries into specific, targeted search terms | ||
| 2. Use the duckduckgo_search tool to find relevant information | ||
| 3. Analyze and synthesize information from multiple sources when possible | ||
| 4. Explain why the information is relevant and how it connects to the query | ||
| 5. Cite your sources when providing information | ||
| 6. If you're unsure about something, say so and explain why | ||
| 7. Provide clear, well-structured responses with key findings highlighted | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| name: str, | ||
| model_client: ChatCompletionClient, | ||
| description: Optional[str] = None, | ||
| system_message: Optional[str] = None, | ||
| **kwargs: Any, | ||
| ) -> None: | ||
| """ | ||
| Initialize a DuckDuckGo Search Agent. | ||
|
|
||
| Args: | ||
| name (str): The name of the agent | ||
| model_client (ChatCompletionClient): The model client to use for generating responses | ||
| description (Optional[str]): A description of the agent's capabilities. If not provided, | ||
| a default description will be used. | ||
| system_message (Optional[str]): The system message to use for the agent. If not provided, | ||
| a default message will be used. | ||
| **kwargs: Additional keyword arguments passed to the parent AssistantAgent | ||
| """ | ||
| if description is None: | ||
| description = self.DEFAULT_DESCRIPTION | ||
|
|
||
| if system_message is None: | ||
| system_message = self.DEFAULT_SYSTEM_MESSAGE | ||
|
|
||
| # Create the DuckDuckGo search tool | ||
| search_tool = DuckDuckGoSearchTool() | ||
|
|
||
| # Initialize the parent AssistantAgent with the search tool | ||
| super().__init__( | ||
| name=name, | ||
| model_client=model_client, | ||
| description=description, | ||
| system_message=system_message, | ||
| tools=[search_tool], | ||
| **kwargs, | ||
| ) |
Empty file.
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
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
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
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
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
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
3 changes: 2 additions & 1 deletion
3
python/packages/autogen-ext/src/autogen_ext/tools/mcp/_config.py
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
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
3 changes: 2 additions & 1 deletion
3
python/packages/autogen-ext/src/autogen_ext/tools/mcp/_stdio.py
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
3 changes: 2 additions & 1 deletion
3
python/packages/autogen-ext/src/autogen_ext/tools/mcp/_streamable_http.py
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
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
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
Oops, something went wrong.
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.