AI提效
搜索问答机器人
S
大模型本地知识库时效性和专业性不足的问题。
T
Chat模型+谷歌搜索API
A
流程图
前置准备
大模型的API调用需API Key;
谷歌搜索的API调用需API Key;
获取可编程搜索引擎CSE;
RESTful风格API调用与
import requests
# Step 1.构建请求
url = "https://www.googleapis.com/customsearch/v1"
# Step 2.设置查询参数
params = {
'q': search_term, # 搜索关键词
'key': google_search_key, # 谷歌搜索API Key
'cx': cse_id # CSE ID
}
# Step 3.发送GET请求
response = requests.get(url, params=params)
# Step 4.解析响应
data = response.json()