-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat(tools): add querit search tool #6493
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
workforcloudy-glitch
wants to merge
3
commits into
crewAIInc:main
Choose a base branch
from
workforcloudy-glitch:feat/querit-search-tool
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,98 @@ | ||
| --- | ||
| title: "Querit Search Tool" | ||
| description: "Perform real-time web searches using the Querit Search API" | ||
| icon: "magnifying-glass" | ||
| mode: "wide" | ||
| --- | ||
|
|
||
| The `QueritSearchTool` provides an interface to the Querit Search API, enabling CrewAI agents to retrieve real-time web results from Querit's search infrastructure for LLM applications. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```shell | ||
| uv add 'crewai[tools]' | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Set your Querit API key as an environment variable: | ||
|
|
||
| ```bash | ||
| export QUERIT_API_KEY='your_querit_api_key' | ||
| ``` | ||
|
|
||
| You can create and manage API keys from the Querit dashboard: [querit.ai/en/dashboard/api-keys](https://www.querit.ai/en/dashboard/api-keys). | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```python | ||
| from crewai import Agent, Crew, Task | ||
| from crewai_tools import QueritSearchTool | ||
|
|
||
| querit_tool = QueritSearchTool(count=10) | ||
|
|
||
| researcher = Agent( | ||
| role="Researcher", | ||
| goal="Find current information from the web", | ||
| backstory="An expert researcher who verifies information with live sources.", | ||
| tools=[querit_tool], | ||
| ) | ||
|
|
||
| research_task = Task( | ||
| description="Search for recent developments in large language models.", | ||
| expected_output="A concise summary with cited sources.", | ||
| agent=researcher, | ||
| ) | ||
|
|
||
| crew = Crew(agents=[researcher], tasks=[research_task]) | ||
| result = crew.kickoff() | ||
| print(result) | ||
| ``` | ||
|
|
||
| ## Direct Usage | ||
|
|
||
| ```python | ||
| from crewai_tools import QueritSearchTool | ||
|
|
||
| tool = QueritSearchTool(count=10) | ||
| result = tool.run(query="What is the latest progress on LLMs?") | ||
| print(result) | ||
| ``` | ||
|
|
||
| ## Configuration Options | ||
|
|
||
| The `QueritSearchTool` accepts the following arguments: | ||
|
|
||
| - `query` (str): Required. The search query string. | ||
| - `count` (int): Maximum number of search results to return. Defaults to `10`. | ||
| - `chunksPerDoc` (int): Number of summary chunks to return per document. Defaults to `3` and supports values from `1` to `3`. | ||
| - `site_include` (list[str]): Optional websites to include in the search results. | ||
| - `site_exclude` (list[str]): Optional websites to exclude from the search results. | ||
| - `time_range` (str): Optional time range value passed to Querit as `timeRange.date`. Use `d[number]`, `w[number]`, `m[number]`, `y[number]`, or `YYYY-MM-DDtoYYYY-MM-DD`. | ||
| - `country_include` (list[str]): Optional countries to include in the search results. | ||
| - `language_include` (list[str]): Optional languages to include in the search results. | ||
| - `timeout` (int): Request timeout in seconds. Defaults to `30`. | ||
| - `api_key` (str): Optional Querit API key. If omitted, `QUERIT_API_KEY` is used. | ||
| - `search_url` (str): Optional Querit API endpoint. Defaults to `https://api.querit.ai/v1/search`. | ||
|
|
||
| ## Filter Parameters Example | ||
|
|
||
| Use the flat filter parameters for common Querit filters. Country and language values are passed through to Querit without restricting their allowed values in this tool. `time_range` must use a Querit time range format such as `d7`, `w1`, `m3`, `y1`, or `2022-04-01to2022-07-30`. | ||
|
|
||
| ```python | ||
| from crewai_tools import QueritSearchTool | ||
|
|
||
| tool = QueritSearchTool( | ||
| count=10, | ||
| chunksPerDoc=3, | ||
| site_include=["example.com"], | ||
| site_exclude=["archive.example.com"], | ||
| time_range="w1", | ||
| country_include=["united states"], | ||
| language_include=["english"], | ||
| ) | ||
| ``` | ||
|
|
||
| ## Response Format | ||
|
|
||
| The tool returns the original Querit API JSON response. |
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
95 changes: 95 additions & 0 deletions
95
lib/crewai-tools/src/crewai_tools/tools/querit_search_tool/README.md
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,95 @@ | ||
| # Querit Search Tool | ||
|
|
||
| ## Description | ||
|
|
||
| The `QueritSearchTool` provides an interface to the Querit Search API, enabling CrewAI agents to perform real-time web searches through Querit's API for LLM applications. It supports result limits and Querit filters for sites, time ranges, countries, and languages. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```shell | ||
| uv add 'crewai[tools]' | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Set your Querit API key as an environment variable: | ||
|
|
||
| ```bash | ||
| export QUERIT_API_KEY='your_querit_api_key' | ||
| ``` | ||
|
|
||
| You can create or manage API keys from the Querit dashboard: | ||
|
|
||
| ```text | ||
| https://www.querit.ai/en/dashboard/api-keys | ||
| ``` | ||
|
|
||
| ## Example | ||
|
|
||
| ```python | ||
| from crewai import Agent, Crew, Task | ||
| from crewai_tools import QueritSearchTool | ||
|
|
||
| querit_tool = QueritSearchTool(count=10) | ||
|
|
||
| researcher = Agent( | ||
| role="Researcher", | ||
| goal="Find current information from the web", | ||
| backstory="An expert researcher who verifies information with live sources.", | ||
| tools=[querit_tool], | ||
| ) | ||
|
|
||
| research_task = Task( | ||
| description="Search for recent developments in large language models.", | ||
| expected_output="A concise summary with cited sources.", | ||
| agent=researcher, | ||
| ) | ||
|
|
||
| crew = Crew(agents=[researcher], tasks=[research_task]) | ||
| result = crew.kickoff() | ||
| print(result) | ||
| ``` | ||
|
|
||
| ## Direct Usage | ||
|
|
||
| ```python | ||
| from crewai_tools import QueritSearchTool | ||
|
|
||
| tool = QueritSearchTool(count=10) | ||
| result = tool.run(query="What is the latest progress on LLMs?") | ||
| print(result) | ||
| ``` | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `query` (str): Required. The search query string. | ||
| - `count` (int): Maximum number of search results to return. Defaults to `10`. | ||
| - `chunksPerDoc` (int): Number of summary chunks to return per document. Defaults to `3` and supports values from `1` to `3`. | ||
| - `site_include` (list[str]): Optional websites to include in the search results. | ||
| - `site_exclude` (list[str]): Optional websites to exclude from the search results. | ||
| - `time_range` (str): Optional time range value passed to Querit as `timeRange.date`. Use `d[number]`, `w[number]`, `m[number]`, `y[number]`, or `YYYY-MM-DDtoYYYY-MM-DD`. | ||
| - `country_include` (list[str]): Optional countries to include in the search results. | ||
| - `language_include` (list[str]): Optional languages to include in the search results. | ||
| - `timeout` (int): Request timeout in seconds. Defaults to `30`. | ||
| - `api_key` (str): Optional Querit API key. If omitted, `QUERIT_API_KEY` is used. | ||
| - `search_url` (str): Optional Querit API endpoint. Defaults to `https://api.querit.ai/v1/search`. | ||
|
|
||
| ## Filter Parameters Example | ||
|
|
||
| Use the flat filter parameters for common Querit filters. Country and language values are passed through to Querit without restricting their allowed values in this tool. `time_range` must use a Querit time range format such as `d7`, `w1`, `m3`, `y1`, or `2022-04-01to2022-07-30`. | ||
|
|
||
| ```python | ||
| tool = QueritSearchTool( | ||
| count=10, | ||
| chunksPerDoc=3, | ||
| site_include=["example.com"], | ||
| site_exclude=["archive.example.com"], | ||
| time_range="w1", | ||
| country_include=["united states"], | ||
| language_include=["english"], | ||
| ) | ||
| ``` | ||
|
|
||
| ## Response Format | ||
|
|
||
| The tool returns the original Querit API JSON response. | ||
6 changes: 6 additions & 0 deletions
6
lib/crewai-tools/src/crewai_tools/tools/querit_search_tool/__init__.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,6 @@ | ||
| """Public exports for the Querit search tool package.""" | ||
|
|
||
| from crewai_tools.tools.querit_search_tool.querit_search_tool import QueritSearchTool | ||
|
|
||
|
|
||
| __all__ = ["QueritSearchTool"] |
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.