-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Add search based tools using wikipedia, serper, serp, brave, exa, duckduckgo #412
Conversation
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.
Hello @asiffarhankhan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request adds several new tools based on search engines like Wikipedia, Serper, SerpAPI, Brave, Exa, and DuckDuckGo to the praisonaiagents
library. The changes primarily involve adding new example files in the docs/tools/external/
directory, each demonstrating how to use a specific search tool with the Agent
and PraisonAIAgents
classes. The PR also includes a minor change to .gitignore
to exclude workspace.code-workspace
.
Highlights
- New Search Tools: Introduces example usages for various search-based tools including Wikipedia, Google Serper, SerpAPI, Exa, and DuckDuckGo.
- Agent Integration: Demonstrates how to integrate these search tools with
Agent
andPraisonAIAgents
classes for creating intelligent agents. - Documentation: Adds new markdown files (
.mdx
) to thedocs/tools/external/
directory to provide examples and documentation for the new tools.
Changelog
Click here to see the changelog
- .gitignore
- Added
workspace.code-workspace
to the ignore list.
- Added
- docs/tools/external/duckduckgo-search.mdx
- Added a new example file demonstrating the usage of DuckDuckGo search tool with
Agent
andPraisonAIAgents
.
- Added a new example file demonstrating the usage of DuckDuckGo search tool with
- docs/tools/external/exa-search.mdx
- Added a new example file demonstrating the usage of Exa search tool with
Agent
andPraisonAIAgents
, including a function to search and retrieve webpage contents.
- Added a new example file demonstrating the usage of Exa search tool with
- docs/tools/external/google-serper-search.mdx
- Added a new example file demonstrating the usage of Google Serper search tool with
Agent
andPraisonAIAgents
.
- Added a new example file demonstrating the usage of Google Serper search tool with
- docs/tools/external/serp-search.mdx
- Added a new example file demonstrating the usage of SerpAPI search tool with
Agent
andPraisonAIAgents
.
- Added a new example file demonstrating the usage of SerpAPI search tool with
- docs/tools/external/wikipedia-search.mdx
- Added a new example file demonstrating the usage of Wikipedia search tool with
Agent
andPraisonAIAgents
.
- Added a new example file demonstrating the usage of Wikipedia search tool with
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
From web's vast ocean, knowledge we seek,
With agents and tools, the answers we speak.
Serper and Exa, Wikipedia too,
Unlocking insights, for me and for you.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces several new tools based on different search engines, which enhances the functionality of the praisonaiagents library. The addition of these tools as MDX files aligns with the existing examples, but further standardization is needed as noted in the pull request description. Overall, the changes seem well-structured, but there are some areas that could be improved for clarity and maintainability.
Summary of Findings
- Missing API Key Handling: The
exa-search.mdx
example directly usesos.environ["EXA_API_KEY"]
without proper error handling if the environment variable is not set. This could lead to runtime errors. It's important to include error handling to ensure the application doesn't crash if the API key is missing. - Inconsistent Environment Variable Loading: The
google-serper-search.mdx
example uses bothload_dotenv()
and direct environment variable access. This inconsistency can be confusing and might lead to unexpected behavior if.env
is not properly configured. Standardizing the approach for loading environment variables would improve clarity. - Lack of Standardization in Examples: The pull request description mentions that standardization is yet to be done using titles, imports, etc. This is evident in the different styles and approaches used across the examples. Standardizing these elements would improve consistency and maintainability.
Merge Readiness
The pull request adds valuable search-based tools to the library. However, before merging, it's crucial to address the missing API key handling in exa-search.mdx
and standardize the environment variable loading in google-serper-search.mdx
. Additionally, standardizing the examples in terms of titles, imports, and overall structure would significantly improve the quality and maintainability of the code. I am unable to approve this pull request, and recommend that the above issues be addressed before merging, and that others review and approve this code before merging.
from exa_py import Exa | ||
import os | ||
|
||
exa = Exa(api_key=os.environ["EXA_API_KEY"]) |
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.
It's good to load the API key from the environment, but it's critical to handle the case where the EXA_API_KEY
environment variable is not set. Without this, the program will crash. Consider adding a check to ensure the environment variable is set and provide a helpful error message if it's not.
exa_api_key = os.environ.get("EXA_API_KEY")
if not exa_api_key:
raise ValueError("EXA_API_KEY environment variable not set.")
exa = Exa(api_key=exa_api_key)
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.
@asiffarhankhan there are few suggestions here. You could fix this may be in the next update. For now i will merge
|
||
load_dotenv() | ||
|
||
os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY') |
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.
There's an inconsistency in how the SERPER_API_KEY
is being handled. You're setting it in os.environ
but also getting it using os.getenv
. It's better to stick to one approach. If you're using dotenv
, you should only rely on os.getenv
after calling load_dotenv()
.
# Load the environment variables
load_dotenv()
# Access the API key using os.getenv
os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')
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.
@asiffarhankhan there are few suggestions here. You could fix this may be in the next update. For now i will merge
Added files for various search based tools, It has been pushed as mdx to align with the existing examples. The standardization is yet to be done using titles, imports etc