From 2f67b2a838bfa3e72a66afb240e0ba72f50c8216 Mon Sep 17 00:00:00 2001 From: jasinluo Date: Tue, 21 Apr 2026 21:00:42 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=96=B0=E5=A2=9E=20web=5Fsearch=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=EF=BC=8C=E6=94=AF=E6=8C=81=20duckduckgo=20?= =?UTF-8?q?=E4=B8=8E=20google=20=20=20=20=20=20=20=20=20=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20web=5Ffetch=20=E5=B7=A5=E5=85=B7=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=E6=96=B0=E5=A2=9E=20=E7=9B=B8=E5=85=B3=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E5=92=8C=E4=BD=BF=E7=94=A8=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flake8 | 2 +- docs/mkdocs/en/tool.md | 581 ++++++++++ docs/mkdocs/zh/tool.md | 585 ++++++++++ examples/webfetch_tool/.env | 4 + examples/webfetch_tool/README.md | 278 +++++ examples/webfetch_tool/agent/__init__.py | 5 + examples/webfetch_tool/agent/agent.py | 166 +++ examples/webfetch_tool/agent/config.py | 19 + examples/webfetch_tool/agent/prompts.py | 28 + examples/webfetch_tool/run_agent.py | 213 ++++ examples/websearch_tool/.env | 12 + examples/websearch_tool/README.md | 346 ++++++ examples/websearch_tool/agent/__init__.py | 5 + examples/websearch_tool/agent/agent.py | 149 +++ examples/websearch_tool/agent/config.py | 33 + examples/websearch_tool/agent/prompts.py | 46 + examples/websearch_tool/run_agent.py | 245 +++++ pyproject.toml | 1 + tests/tools/test_websearch_tool.py | 1191 +++++++++++++++++++++ trpc_agent_sdk/tools/__init__.py | 10 + trpc_agent_sdk/tools/_webfetch_tool.py | 705 ++++++++++++ trpc_agent_sdk/tools/_websearch_tool.py | 724 +++++++++++++ 22 files changed, 5347 insertions(+), 1 deletion(-) create mode 100644 examples/webfetch_tool/.env create mode 100644 examples/webfetch_tool/README.md create mode 100644 examples/webfetch_tool/agent/__init__.py create mode 100644 examples/webfetch_tool/agent/agent.py create mode 100644 examples/webfetch_tool/agent/config.py create mode 100644 examples/webfetch_tool/agent/prompts.py create mode 100644 examples/webfetch_tool/run_agent.py create mode 100644 examples/websearch_tool/.env create mode 100644 examples/websearch_tool/README.md create mode 100644 examples/websearch_tool/agent/__init__.py create mode 100644 examples/websearch_tool/agent/agent.py create mode 100644 examples/websearch_tool/agent/config.py create mode 100644 examples/websearch_tool/agent/prompts.py create mode 100644 examples/websearch_tool/run_agent.py create mode 100644 tests/tools/test_websearch_tool.py create mode 100644 trpc_agent_sdk/tools/_webfetch_tool.py create mode 100644 trpc_agent_sdk/tools/_websearch_tool.py diff --git a/.flake8 b/.flake8 index ff9a93a..e0688a3 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] max-line-length = 120 -ignore = E402 +ignore = E402, W503 diff --git a/docs/mkdocs/en/tool.md b/docs/mkdocs/en/tool.md index f3d4a8f..ed2823c 100644 --- a/docs/mkdocs/en/tool.md +++ b/docs/mkdocs/en/tool.md @@ -2260,3 +2260,584 @@ print(regular_tool.is_streaming) # False - [Streaming Tools Complete Example](../../../examples/streaming_tools/run_agent.py) - Streaming tools running example - [Function Tools Documentation](#function-tools) - Usage of standard function tools + +## WebFetchTool + +`WebFetchTool` is the built-in **single-URL web fetching tool** in the trpc-agent-python framework. When an Agent needs to read, summarize, or cite content from a public web page, it can use this tool to issue a single HTTP GET request. The framework then converts the response into structured text consumable by the LLM: HTML is reduced to plain Markdown text, textual MIME types such as `text/*` and `application/json` are returned as-is, and binary responses are rejected with a structured error. + +### Features + +- **HTTP GET**: HTML is automatically converted to plain Markdown text, with non-content blocks such as `