Skip to content
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

fix(#2008): Changes GoogleSearch to GoogleSearchTools #2029

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cookbook/tools/googlesearch_tools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from agno.agent import Agent
from agno.tools.googlesearch import GoogleSearch
from agno.tools.googlesearch import GoogleSearchTools

agent = Agent(
tools=[GoogleSearch()],
tools=[GoogleSearchTools()],
description="You are a news agent that helps users find the latest news.",
instructions=[
"Given a topic by the user, respond with 4 latest news items about that topic.",
Expand Down
6 changes: 3 additions & 3 deletions cookbook/workflows/startup_idea_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.storage.workflow.sqlite import SqliteWorkflowStorage
from agno.tools.googlesearch import GoogleSearch
from agno.tools.googlesearch import GoogleSearchTools
from agno.utils.log import logger
from agno.utils.pprint import pprint_run_response
from agno.workflow import RunEvent, RunResponse, Workflow
Expand Down Expand Up @@ -94,7 +94,7 @@ class StartupIdeaValidator(Workflow):

market_research_agent: Agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[GoogleSearch()],
tools=[GoogleSearchTools()],
instructions=[
"You are provided with a startup idea and the company's mission and objectives. ",
"Estimate the total addressable market (TAM), serviceable available market (SAM), and serviceable obtainable market (SOM). ",
Expand All @@ -110,7 +110,7 @@ class StartupIdeaValidator(Workflow):

competitor_analysis_agent: Agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[GoogleSearch()],
tools=[GoogleSearchTools()],
instructions=[
"You are provided with a startup idea and some market research related to the idea. ",
"Identify existing competitors in the market. ",
Expand Down
34 changes: 32 additions & 2 deletions libs/agno/agno/tools/googlesearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import warnings
from typing import Any, Dict, List, Optional

from agno.tools import Toolkit
Expand All @@ -15,9 +16,9 @@
raise ImportError("`pycountry` not installed. Please install using `pip install pycountry`")


class GoogleSearch(Toolkit):
class GoogleSearchTools(Toolkit):
"""
GoogleSearch is a Python library for searching Google easily.
GoogleSearchTools is a tool for searching Google easily.
It uses requests and BeautifulSoup4 to scrape Google.

Args:
Expand Down Expand Up @@ -86,3 +87,32 @@ def google_search(self, query: str, max_results: int = 5, language: str = "en")
)

return json.dumps(res, indent=2)


class GoogleSearch(GoogleSearchTools):
"""
Deprecated: Use `GoogleSearchTools` instead.

This class is maintained for backward compatibility and will be removed in a future version.
"""

def __init__(
self,
fixed_max_results: Optional[int] = None,
fixed_language: Optional[str] = None,
headers: Optional[Any] = None,
proxy: Optional[str] = None,
timeout: Optional[int] = 10,
):
warnings.warn(
"GoogleSearch class is deprecated. Please use `GoogleSearchTools` instead.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(
fixed_max_results=fixed_max_results,
fixed_language=fixed_language,
headers=headers,
proxy=proxy,
timeout=timeout,
)
Comment on lines +92 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can skip class. Were you trying to have backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i was keeping backward compatibility so that we can release it in a patch update instead of a major update