All pages
Powered by GitBook
1 of 1

Loading...

BaiduSearch

BaiduSearch enables an Agent to search the web for information using the Baidu search engine.

​Prerequisites

The following example requires the baidusearch library. To install BaiduSearch, run the following command:

Example

cookbook/tools/baidusearch_tools.py

Toolkit Params

Parameter
Type
Default
Description

Toolkit Functions

Function
Description

Information

  • View on

pip install -U baidusearch

proxy

str

-

Specifies a single proxy address as a string to be used for the HTTP requests.

timeout

int

10

Sets the timeout for HTTP requests, in seconds.

fixed_max_results

int

-

Sets a fixed number of maximum results to return. No default is provided, must be specified if used.

fixed_language

str

-

Set the fixed language for the results.

headers

Any

-

baidu_search

Use this function to search Baidu for a query.

​
​
​
​
Github

Headers to be used in the search request.

from bitca.agent import Agent
from bitca.tools.baidusearch import BaiduSearch

agent = Agent(
    tools=[BaiduSearch()],
    description="You are a search agent that helps users find the most relevant information using Baidu.",
    instructions=[
        "Given a topic by the user, respond with the 3 most relevant search results about that topic.",
        "Search for 5 results and select the top 3 unique items.",
        "Search in both English and Chinese.",
    ],
    show_tool_calls=True,
)
agent.print_response("What are the latest advancements in AI?", markdown=True)