-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Google Search API #3049
Open
MohammedNagdy
wants to merge
11
commits into
microsoft:0.2
Choose a base branch
from
MohammedNagdy:google-search-api
base: 0.2
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.
+672
−9
Open
Google Search API #3049
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f4ca7c0
Refactor for broswer utils to add more browsers for websurfer
MohammedNagdy f8d684a
Created a base class for searchers and added Google search also adjus…
MohammedNagdy 7e4d8ec
dev container
mnagdycnn 14bdd4a
Added the bing and the google browser to the websurfer agent
MohammedNagdy 869bcf3
Added a dynamic browser for the web surfer agent
MohammedNagdy 2423a11
Merge branch 'main' into google-search-api
MohammedNagdy 81ef40d
Created a factory method to instatiate text browsers, adjusted some s…
MohammedNagdy aec42be
Merge remote-tracking branch 'refs/remotes/origin/main'
MohammedNagdy bd45a68
Merge branch 'main' into google-search-api
MohammedNagdy 65b096c
Using enums for browser for extendabilty
MohammedNagdy d467dc4
Update test/test_browser_utils_google.py
rysweet 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 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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10 | ||
# | ||
# Update the OS and maybe install packages | ||
# | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
# add git lhs to apt | ||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \ | ||
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.deb \ | ||
&& dpkg -i quarto-1.5.23-linux-${arch}.deb \ | ||
&& rm -rf /var/lib/apt/lists/* quarto-1.5.23-linux-${arch}.deb | ||
ENV DEBIAN_FRONTEND=dialog | ||
# For docs | ||
RUN npm install --global yarn | ||
RUN pip install --upgrade pip | ||
RUN pip install pydoc-markdown | ||
RUN pip install pyyaml | ||
RUN pip install colored | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10 | ||
|
||
# | ||
# Update the OS and maybe install packages | ||
# | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# add git lhs to apt | ||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \ | ||
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.deb \ | ||
&& dpkg -i quarto-1.5.23-linux-${arch}.deb \ | ||
&& rm -rf /var/lib/apt/lists/* quarto-1.5.23-linux-${arch}.deb | ||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
# For docs | ||
RUN npm install --global yarn | ||
RUN pip install --upgrade pip | ||
RUN pip install pydoc-markdown | ||
RUN pip install pyyaml | ||
RUN pip install colored |
This file contains 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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-toolsai.jupyter", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"GitHub.copilot" | ||
], | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
} | ||
} | ||
}, | ||
"dockerFile": "Dockerfile", | ||
"updateContentCommand": "pip install -e . pre-commit && pre-commit install" | ||
} | ||
{ | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-toolsai.jupyter", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"GitHub.copilot" | ||
], | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
} | ||
} | ||
}, | ||
"dockerFile": "Dockerfile", | ||
"updateContentCommand": "pip install -e . pre-commit && pre-commit install" | ||
} |
This file contains 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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10 | ||
# | ||
# Update the OS and maybe install packages | ||
# | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
# add git lhs to apt | ||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
ENV DEBIAN_FRONTEND=dialog | ||
# For docs | ||
RUN npm install --global yarn | ||
RUN pip install --upgrade pip | ||
RUN pip install pydoc-markdown | ||
#------------------------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
#------------------------------------------------------------------------------------------------------------- | ||
|
||
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10 | ||
|
||
# | ||
# Update the OS and maybe install packages | ||
# | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# add git lhs to apt | ||
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash | ||
|
||
RUN apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get -y install --no-install-recommends build-essential npm git-lfs \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
ENV DEBIAN_FRONTEND=dialog | ||
|
||
# For docs | ||
RUN npm install --global yarn | ||
RUN pip install --upgrade pip | ||
RUN pip install pydoc-markdown |
This file contains 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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
{ | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-toolsai.jupyter", | ||
"visualstudioexptteam.vscodeintellicode" | ||
], | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
} | ||
} | ||
}, | ||
"dockerFile": "Dockerfile", | ||
"updateContentCommand": "cd samples/apps/autogen-studio && pip install -e . && sudo npm install -g gatsby-cli && cd frontend && yarn install && yarn build" | ||
} | ||
{ | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-toolsai.jupyter", | ||
"visualstudioexptteam.vscodeintellicode" | ||
], | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "/bin/bash" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "bash" | ||
} | ||
} | ||
}, | ||
"dockerFile": "Dockerfile", | ||
"updateContentCommand": "cd samples/apps/autogen-studio && pip install -e . && sudo npm install -g gatsby-cli && cd frontend && yarn install && yarn build" | ||
} |
This file contains 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 |
---|---|---|
|
@@ -19,6 +19,7 @@ __pycache__/ | |
*.so | ||
|
||
# Distribution / packaging | ||
.devcontainer/ | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
|
Empty file.
This file contains 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 |
---|---|---|
|
@@ -9,13 +9,16 @@ | |
from typing_extensions import Annotated | ||
|
||
from ... import Agent, AssistantAgent, ConversableAgent, GroupChat, GroupChatManager, OpenAIWrapper, UserProxyAgent | ||
from ...browser_utils import SimpleTextBrowser | ||
from ...browser_utils.bing_browser import BingTextBrowser | ||
from ...browser_utils.google_broswer import GoogleTextBrowser | ||
from ...code_utils import content_str | ||
from ...oai.openai_utils import filter_config | ||
from ...token_count_utils import count_token, get_max_token_limit | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
BROWSERS = {"google": GoogleTextBrowser, "bing": BingTextBrowser} | ||
|
||
|
||
class WebSurferAgent(ConversableAgent): | ||
"""(In preview) An agent that acts as a basic web surfer that can search the web and visit web pages.""" | ||
|
@@ -40,6 +43,7 @@ def __init__( | |
llm_config: Optional[Union[Dict, Literal[False]]] = None, | ||
summarizer_llm_config: Optional[Union[Dict, Literal[False]]] = None, | ||
default_auto_reply: Optional[Union[str, Dict, None]] = "", | ||
browser_name: str = "bing", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we use enum for this lookup table? |
||
browser_config: Optional[Union[Dict, None]] = None, | ||
): | ||
super().__init__( | ||
|
@@ -58,7 +62,9 @@ def __init__( | |
self._create_summarizer_client(summarizer_llm_config, llm_config) | ||
|
||
# Create the browser | ||
self.browser = SimpleTextBrowser(**(browser_config if browser_config else {})) | ||
self.browser_name = browser_name | ||
chosen_browser = BROWSERS[self.browser_name] | ||
self.browser = chosen_browser(**(browser_config if browser_config else {})) | ||
|
||
inner_llm_config = copy.deepcopy(llm_config) | ||
|
||
|
@@ -134,7 +140,7 @@ def _browser_state() -> Tuple[str, str]: | |
description="Perform an INFORMATIONAL web search query then return the search results.", | ||
) | ||
def _informational_search(query: Annotated[str, "The informational web search query to perform."]) -> str: | ||
self.browser.visit_page(f"bing: {query}") | ||
self.browser.visit_page(f"{self.browser_name}: {query}") | ||
header, content = _browser_state() | ||
return header.strip() + "\n=======================\n" + content | ||
|
||
|
@@ -144,7 +150,7 @@ def _informational_search(query: Annotated[str, "The informational web search qu | |
description="Perform a NAVIGATIONAL web search query then immediately navigate to the top result. Useful, for example, to navigate to a particular Wikipedia article or other known destination. Equivalent to Google's \"I'm Feeling Lucky\" button.", | ||
) | ||
def _navigational_search(query: Annotated[str, "The navigational web search query to perform."]) -> str: | ||
self.browser.visit_page(f"bing: {query}") | ||
self.browser.visit_page(f"{self.browser_name}: {query}") | ||
|
||
# Extract the first linl | ||
m = re.search(r"\[.*?\]\((http.*?)\)", self.browser.page_content) | ||
|
Empty file.
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.
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.
here enums too, or at least some configuration so that users can register new text browsers if they implement new ones (like wikimedia servers for example) maybe a better idea is to pass the textbroser instance to the agent factory itself