For the complete documentation index, see llms.txt. This page is also available as Markdown.

如何将ThorData与LlamaIndex集成

将 ThorData SERP API 连接到 LlamaIndex,让您的代理能够执行即时网页搜寻、图片搜寻、新闻搜寻,并取得结构化搜寻结果。 ThorData 支援覆盖全球 190 个国家/地区,适用于 AI Agent、SEO 工具、市场研究和搜寻驱动型应用。

取得您的 ThorData API 密钥

安装

安装所需的套件:

python -m pip install llama-index-tools-thordata-serp

使用范例

以下范例示范如何将 ThorData 工具与 LlamaIndex 搭配使用。

llm = OpenAI(model="gpt-4o", api_key="your-api-key")

thordata_tool = thordataToolSpec(api_key="your-api-key", zone="unlocker")

tool_list = thordata_tool.to_tool_list()

for tool in tool_list:
tool.original_description = tool.metadata.description
tool.metadata.description = "thordata web scraping tool"

agent = OpenAIAgent.from_tools(tools=tool_list, llm=llm)

query = (
"Find and summarize the latest news about AI from major tech news sites"
)
tool_descriptions = "\n\n".join(
[
f"Tool Name: {tool.metadata.name}\nTool Description: {tool.original_description}"
for tool in tool_list
]
)

query_with_descriptions = f"{tool_descriptions}\n\nQuery: {query}"

response = agent.chat(query_with_descriptions)
print(response)

Last updated

Was this helpful?