特定query干预
更新时间:2026-02-09
新增干预项
接口定义
| URL | https://qianfan.baidubce.com/v2/ai_search/web_search/intervention |
|---|---|
| Method | POST |
| Content-Type | application/json |
请求结构
Plain Text
1POST /v2/ai_search/web_search/intervention
2Content-Type: application/json
3Authorization: Bearer <API Key>
4{
5 "query": "2026年春节放假时间",
6 "config_id": "",
7 "query_match_strategy": {
8 "name": "exact"
9 },
10 "result": {
11 "documents": [
12 {
13 "id": 1,
14 "url": "https://www.gov.cn/zhengce/content/2025-11/20/content_6968789.htm",
15 "title": "2026年春节放假安排通知",
16 "date": "2025-11-20",
17 "content": "2026年春节放假时间为2月10日至16日放假调休,共7天。2月8日(星期日)、2月17日(星期一)上班。",
18 "icon": "https://www.gov.cn/favicon.ico",
19 "web_anchor": "中国政府网",
20 "type": "web",
21 "website": "www.gov.cn",
22 "video": null,
23 "image": null,
24 "is_aladdin": false,
25 "aladdin": null,
26 "snippet": "2026年春节放假时间为2月10日至16日放假调休,共7天...",
27 "web_extensions": null,
28 "rerank_score": 0.98,
29 "authority_score": 0.95,
30 "markdown_text": "## 2026年春节放假安排\n\n2026年春节放假时间为2月10日至16日放假调休,共7天。2月8日(星期日)、2月17日(星期一)上班。"
31 },
32 {
33 "id": 2,
34 "url": "https://example.com/2026-spring-festival.jpg",
35 "title": "2026春节放假日历",
36 "date": "2025-11-21",
37 "content": "2026年春节放假日历高清版,包含调休安排和出行提示。",
38 "icon": "",
39 "web_anchor": "",
40 "type": "image",
41 "website": "",
42 "video": null,
43 "image": {
44 "url": "https://example.com/2026-spring-festival.jpg",
45 "height": "1080",
46 "width": "1920"
47 },
48 "is_aladdin": false,
49 "aladdin": null,
50 "snippet": "",
51 "web_extensions": {
52 "images": [
53 {
54 "url": "https://example.com/2026-spring-festival-1.jpg",
55 "height": "720",
56 "width": "1080"
57 }
58 ]
59 },
60 "rerank_score": null,
61 "authority_score": null,
62 "markdown_text": ""
63 }
64 ]
65 }
66}
Header 参数
| 字段 | 值 | 说明 |
|---|---|---|
| Content-Type | application/json | 必填 |
| Authorization | XXXXX | XXXXX 为调用token,获取API Key |
请求参数
| 字段 | 类型 | 是否必填 | 说明 | |
|---|---|---|---|---|
| query | string | 是 | 问答query,不超过 256个字符 | |
| config_id | string | 是 | 策略配置id,需要提前调用配置接口配置id(config_id配置请参考文档) | |
| query_match_strategy | QueryMatchStrategy | 是 | query匹配策略 | |
| result | Result | 是 | 干预策略 |
QueryMatchStrategy结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| name | string | 是 | 匹配策略: exact - 完全匹配 semantic - 语义 keyword - 关键词匹配 | |
| similarity_threshold | float | 否 | 语义匹配阀值, 0~1 之间,默认 0.9 | |
| keywords | array |
否 | 关键词匹配时,设置用于匹配的关键词,长度不超过256 |
Result结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| documents | array |
是 | 预置回答策略 |
Document结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| id | int | 是 | 文档唯一标识 | |
| url | string | 是 | 文档URL地址 | |
| title | string | 否 | 文档标题 | |
| date | string | 否 | 网页发布时间 | |
| content | string | 否 | 文档正文内容 | |
| icon | string | 否 | 图标URL | |
| web_anchor | string | 否 | 网页来源 | |
| type | string | 否 | 资源类型 | |
| website | string | 否 | 站点名称。 | |
| snippet | string | 否 | 摘要文本 | |
| rerank_score | float | 否 | 重排序分数 | |
| authority_score | float | 否 | 权威性分数 | |
| markdown_text | string | 否 | Markdown格式文本 | |
| is_aladdin | bool | 否 | 是否来自阿拉丁 | |
| aladdin | Object | 否 | 阿拉丁详细内容,参考文档。 | |
| image | Image | 否 | 图片信息 | |
| video | Video | 否 | 视频信息 | |
| web_extesions | WebExtensions | 否 | 网页扩展信息 |
Document.Image对象
| 参数名称 | 数据类型 | 必填 | 描述 |
|---|---|---|---|
| url | string | 否 | 图片链接。 |
| height | string | 否 | 图片高度。 |
| width | string | 否 | 图片宽度。 |
Document.Video对象
| 参数名称 | 数据类型 | 必填 | 描述 |
|---|---|---|---|
| url | string | 否 | 视频链接。 |
| height | string | 否 | 视频高度。 |
| width | string | 否 | 视频宽度。 |
| size | string | 否 | 视频大小,单位Bytes。 |
| duration | string | 否 | 视频长度,单位秒。 |
| hover_pic | string | 否 | 视频封面图。 |
Document.WebExtensions
| 参数名称 | 数据类型 | 必填 | 描述 |
|---|---|---|---|
| images | array<Image> | 否 | 网页相关图片 |
| +images[0].url | string | 否 | 图片链接 |
| +images[0].height | string | 否 | 图片高度 |
| +images[0].width | string | 否 | 图片宽度 |
响应示例
Plain Text
1{"request_id": "123"}
删除干预项
请求结构
Plain Text
1DELETE /v2/ai_search/web_search/intervention HTTP/1.1
2HOST: qianfan.baidubce.com
3Authorization: Bearer <API Key>
4Content-Type: application/json
5query=%E5%B0%8F%E7%B1%B3%E6%98%AF%E7%BB%84%E8%A3%85%E5%8E%82%E5%90%97%EF%BC%9F?
Header参数
| 字段 | 值 | 说明 |
|---|---|---|
| Authorization | XXXXX | XXXXX为调用token,获取API Key |
请求params入参
| 字段名 | 字段类型 | 是否必须 | 说明 | |
|---|---|---|---|---|
| query | str | 是 | 请求前需对 query 参数进行 URL Encode 编码 | |
| config_id | str | 否 | 用户配置ID。如果为空,则只查询全局干预;如果不为空,则先查全局干预,再根据 config_id 查询用户特定的干预策略 |
调用示例
Plain Text
1curl -X "DELETE" \
2-H "Authorization: Bearer <API Key> " \
3--location 'https://qianfan.baidubce.com/v2/ai_search/web_search/intervention?query=%E5%B0%8F%E7%B1%B3%E6%98%AF%E7%BB%84%E8%A3%85%E5%8E%82%E5%90%97%EF%BC%9F'
响应参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| request_id | string | 是 | 请求request_id |
| code | string | 否 | 错误代码,当发生异常时返回 |
| message | string | 否 | 错误消息,当发生异常时返回 |
响应示例
Plain Text
1{"request_id": "123"}
分页查询干预项
请求结构
Plain Text
1GET /v2/ai_search/web_search/intervention HTTP/1.1
2HOST: qianfan.baidubce.com
3Authorization: Bearer <API Key>
4Content-Type: application/json
5?offset=2&limit=4
Header参数
| 字段 | 值 | 说明 |
|---|---|---|
| Authorization | XXXXX | XXXXX为调用token,获取API Key |
请求params入参
| 字段名 | 字段类型 | 是否必须 | 说明 | |
|---|---|---|---|---|
| offset | str | 否 | 偏移量,默认为0 | |
| limit | str | 否 | 条数限制,最大不超过 100,默认为10 | |
| config_id | str | 是 | 配置id |
调用示例
Plain Text
1curl --location 'https://qianfan.baidubce.com/v2/ai_search/web_search/intervention?offset=2&limit=4' \
2--header 'Content-Type: application/json' \
3--header 'Authorization: Bearer <API Key>' \
响应格式
| 字段 | 类型 | 必填 | ||
|---|---|---|---|---|
| request_id | string | 是 | 请求request_id | |
| limit | int | 是 | 分页大小 | |
| offset | int | 是 | 分页偏移 | |
| total | int | 是 | 结果总数 | |
| code | string | 否 | 错误代码,当发生异常时返回 | |
| message | string | 否 | 错误消息,当发生异常时返回 | |
| items | array | 是 | 问答策略数组 |
items结构
| 字段 | 类型 | 必填 | ||
|---|---|---|---|---|
| id | int | 是 | 文档唯一标识 | |
| query | string | 是 | 搜索query | |
| config_id | string | 是 | 配置id | |
| intervention_strategy | object | 是 | 干预策略 |
intervention_strategy结构
| 字段 | 类型 | 必填 | ||
|---|---|---|---|---|
| query_match_strategy | QueryMatchStrategy | 是 | query匹配策略 | |
| result | Result | 是 | 干预结果 |
QueryMatchStrategy结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| name | string | 是 | 匹配策略名字: exact - 完全匹配 semantic - 语义 keyword - 关键词匹配 | |
| similarity_threshold | float | 否 | 语义匹配阀值, 0~1 之间,默认 0.9 | |
| keywords | array |
否 | 关键词匹配时,设置用于匹配的关键词,长度不超过256 |
Result结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| documents | array |
是 | 预置回答策略 |
Document结构
| 字段 | 类型 | 必填 | 说明 | |
|---|---|---|---|---|
| id | int | 是 | 文档唯一标识 | |
| url | string | 是 | 文档URL地址 | |
| title | string | 否 | 文档标题 | |
| date | string | 否 | 网页发布时间 | |
| content | string | 否 | 文档正文内容 | |
| icon | string | 否 | 图标URL | |
| web_anchor | string | 否 | 网页来源 | |
| type | string | 否 | 资源类型 | |
| website | string | 否 | 站点名称。 | |
| snippet | string | 否 | 摘要文本 | |
| rerank_score | float | 否 | 重排序分数 | |
| authority_score | float | 否 | 权威性分数 | |
| markdown_text | string | 否 | Markdown格式文本 | |
| is_aladdin | bool | 否 | 是否来自阿拉丁 | |
| aladdin | Object | 否 | 阿拉丁详细内容 | |
| image | Image | 否 | 图片信息 | |
| video | Video | 否 | 视频信息 | |
| web_extesions | WebExtensions | 否 | 网页扩展信息 |
响应示例
Plain Text
1{
2 "items": [
3 {
4 "config_id": "",
5 "id": 9,
6 "intervention_strategy": {
7 "query_match_strategy": {
8 "name": "exact"
9 },
10 "result": {
11 "documents": [
12 {
13 "id": 1,
14 "url": "https://www.gov.cn/zhengce/content/2025-11/20/content_6968789.htm",
15 "title": "2026年春节放假安排通知",
16 "date": "2025-11-20",
17 "content": "2026年春节放假时间为2月10日至16日放假调休,共7天。2月8日(星期日)、2月17日(星期一)上班。",
18 "icon": "https://www.gov.cn/favicon.ico",
19 "web_anchor": "中国政府网",
20 "type": "web",
21 "website": "www.gov.cn",
22 "video": null,
23 "image": null,
24 "is_aladdin": false,
25 "aladdin": null,
26 "snippet": "2026年春节放假时间为2月10日至16日放假调休,共7天...",
27 "web_extensions": null,
28 "rerank_score": 0.98,
29 "authority_score": 0.95,
30 "markdown_text": "## 2026年春节放假安排\n\n2026年春节放假时间为2月10日至16日放假调休,共7天。2月8日(星期日)、2月17日(星期一)上班。"
31 },
32 {
33 "id": 2,
34 "url": "https://example.com/2026-spring-festival.jpg",
35 "title": "2026春节放假日历",
36 "date": "2025-11-21",
37 "content": "2026年春节放假日历高清版,包含调休安排和出行提示。",
38 "icon": "",
39 "web_anchor": "",
40 "type": "image",
41 "website": "",
42 "video": null,
43 "image": {
44 "url": "https://example.com/2026-spring-festival.jpg",
45 "height": "1080",
46 "width": "1920"
47 },
48 "is_aladdin": false,
49 "aladdin": null,
50 "snippet": "",
51 "web_extensions": {
52 "images": [
53 {
54 "url": "https://example.com/2026-spring-festival-1.jpg",
55 "height": "720",
56 "width": "1080"
57 }
58 ]
59 },
60 "markdown_text": ""
61 },
62 {
63 "id": 3,
64 "url": "https://example.com/2026-spring-festival.mp4",
65 "title": "2026春节放假政策解读",
66 "date": "2025-11-22",
67 "content": "官方解读2026年春节放假安排,解答调休、加班工资等问题。",
68 "icon": "",
69 "web_anchor": "",
70 "type": "video",
71 "website": "",
72 "video": {
73 "url": "https://example.com/2026-spring-festival.mp4",
74 "height": "1080",
75 "width": "1920",
76 "size": "83886080",
77 "duration": "180",
78 "hover_pic": "https://example.com/2026-spring-festival-cover.jpg"
79 },
80 "image": null,
81 "is_aladdin": false,
82 "aladdin": null,
83 "snippet": "",
84 "web_extensions": null,
85 "markdown_text": ""
86 }
87 ]
88 }
89 },
90 "query": "2026年春节放假时间"
91 }
92 ],
93 "limit": 10,
94 "offset": 0,
95 "request_id": "",
96 "total": 1
97}
