外观
Gemini网页上下文
您可以使用网址上下文工具,为 Gemini 提供网址作为提示的额外上下文。然后,该模型可以从网址中检索内容,并使用这些内容来为其回答提供依据并塑造其回答。
此工具适用于以下任务:
- 从文章中提取关键数据点或要点
- 比较多个关联中的信息
- 综合来自多个来源的数据
- 根据特定网页的内容回答问题
- 出于特定用途(例如撰写工作说明或创建测试题目)分析内容
示例1:
仅包含网址上下文的代码示例
js
curl "https://mishu.one/google/v1beta/models/gemini-2.5-flash:generateContent?key=$MISHU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [
{"text": "Compare recipes from YOUR_URL1 and YOUR_URL2"}
]
}
],
"tools": [
{
"url_context": {}
}
]
}' > result.json
cat result.json示例2:
使用“依托 Google 搜索进行接地”功能的代码示例
js
curl "https://mishu.one/google/v1beta/models/gemini-2.5-flash:generateContent?key=$MISHU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [
{"text": "Give me three day events schedule based on YOUR_URL. Also let me know what needs to taken care of considering weather and commute."}
]
}
],
"tools": [
{
"url_context": {}
},
{
"google_search": {}
}
]
}' > result.json
cat result.json