Skip to content

Add web search and page viewing tools for code agent#869

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/cb057cab-ce6b-46ed-b7f6-f91a7f12a7e5
Draft

Add web search and page viewing tools for code agent#869
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/cb057cab-ce6b-46ed-b7f6-f91a7f12a7e5

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 16, 2025

This PR adds web search and page viewing capabilities to the code agent, allowing it to access documentation and other online resources.

Changes

  1. Created two new tool functions:

    • web_search.py: Implements a web search tool using the SerpAPI to search the web and return results
    • web_page_view.py: Implements a web page viewing tool to extract content from web pages
  2. Added corresponding tool classes in tools.py:

    • WebSearchTool: Tool for searching the web
    • WebPageViewTool: Tool for viewing web page content
  3. Updated agent creation functions to include the new tools:

    • Added tools to create_codebase_agent
    • Added tools to create_chat_agent
    • Added tools to get_workspace_tools

Usage

The web search tool requires a SERP_API_KEY environment variable to be set. Users can obtain a key from https://serpapi.com/.

Example usage:

# Search the web
web_search(query="python requests library documentation", num_results=5)

# View a web page
web_page_view(url="https://docs.python.org/3/library/requests.html", max_length=5000)

These tools enable the agent to look up documentation, tutorials, and other online resources to better assist developers.

Resolves: CG-12183

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant