From 1697b4cacbded1cb1376267273068f07442b2d29 Mon Sep 17 00:00:00 2001 From: Samuel Mallet <69467005+SuperMuel@users.noreply.github.com> Date: Sun, 28 Jul 2024 20:09:55 +0200 Subject: [PATCH] Add docs for new parameters to SerperDevTool (#993) --- docs/tools/SerperDevTool.md | 67 ++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/docs/tools/SerperDevTool.md b/docs/tools/SerperDevTool.md index ca8611a991..539906f20b 100644 --- a/docs/tools/SerperDevTool.md +++ b/docs/tools/SerperDevTool.md @@ -29,5 +29,70 @@ To effectively use the `SerperDevTool`, follow these steps: 2. **API Key Acquisition**: Acquire a `serper.dev` API key by registering for a free account at `serper.dev`. 3. **Environment Configuration**: Store your obtained API key in an environment variable named `SERPER_API_KEY` to facilitate its use by the tool. +## Parameters + +The `SerperDevTool` comes with several parameters that will be passed to the API : + +- **search_url**: The URL endpoint for the search API. (Default is `https://google.serper.dev/search`) + +- **country**: Optional. Specify the country for the search results. +- **location**: Optional. Specify the location for the search results. +- **locale**: Optional. Specify the locale for the search results. +- **n_results**: Number of search results to return. Default is `10`. + +The values for `country`, `location`, `lovale` and `search_url` can be found on the [Serper Playground](https://serper.dev/playground). + +## Example with Parameters + +Here is an example demonstrating how to use the tool with additional parameters: + +```python +from crewai_tools import SerperDevTool + +tool = SerperDevTool( + search_url="https://google.serper.dev/scholar", + n_results=2, +) + +print(tool.run(search_query="ChatGPT")) + +# Using Tool: Search the internet + +# Search results: Title: Role of chat gpt in public health +# Link: https://link.springer.com/article/10.1007/s10439-023-03172-7 +# Snippet: … ChatGPT in public health. In this overview, we will examine the potential uses of ChatGPT in +# --- +# Title: Potential use of chat gpt in global warming +# Link: https://link.springer.com/article/10.1007/s10439-023-03171-8 +# Snippet: … as ChatGPT, have the potential to play a critical role in advancing our understanding of climate +# --- + +``` + +```python +from crewai_tools import SerperDevTool + +tool = SerperDevTool( + country="fr", + locale="fr", + location="Paris, Paris, Ile-de-France, France", + n_results=2, +) + +print(tool.run(search_query="Jeux Olympiques")) + +# Using Tool: Search the internet + +# Search results: Title: Jeux Olympiques de Paris 2024 - Actualités, calendriers, résultats +# Link: https://olympics.com/fr/paris-2024 +# Snippet: Quels sont les sports présents aux Jeux Olympiques de Paris 2024 ? · Athlétisme · Aviron · Badminton · Basketball · Basketball 3x3 · Boxe · Breaking · Canoë ... +# --- +# Title: Billetterie Officielle de Paris 2024 - Jeux Olympiques et Paralympiques +# Link: https://tickets.paris2024.org/ +# Snippet: Achetez vos billets exclusivement sur le site officiel de la billetterie de Paris 2024 pour participer au plus grand événement sportif au monde. +# --- + +``` + ## Conclusion -By integrating the `SerperDevTool` into Python projects, users gain the ability to conduct real-time, relevant searches across the internet directly from their applications. By adhering to the setup and usage guidelines provided, incorporating this tool into projects is streamlined and straightforward. +By integrating the `SerperDevTool` into Python projects, users gain the ability to conduct real-time, relevant searches across the internet directly from their applications. The updated parameters allow for more customized and localized search results. By adhering to the setup and usage guidelines provided, incorporating this tool into projects is streamlined and straightforward.