You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为导入Azure OpenAI的文档自定义标题?

自定义Azure OpenAI On Your Data的文档标题

Azure OpenAI On Your Data完全支持自定义文档标题,以下是几种可行的实现方式:

1. 导入数据时指定自定义标题

在将文本文件上传到Azure存储(如Blob存储)时,可为每个文件添加自定义元数据(例如x-ms-meta-title)来记录目标标题。后续创建Azure搜索索引时,将该元数据字段映射到索引的title字段,或新增自定义字段(如custom_title)存储标题。

如果用Python SDK批量导入数据,可直接在文档对象中设置title字段值:

# 示例:处理文档时添加自定义标题
document = {
    "id": "doc1",
    "content": "文档内容...",
    "title": "我的自定义标题",
    # 其他必要字段
}
# 将文档上传到Azure搜索索引
search_client.upload_documents([document])

2. API调用时指定字段映射

在调用chat.completions.create接口时,通过extra_body.data_sources[0].parameters.fields_mapping参数,指定搜索索引中存储自定义标题的字段。API会优先使用该字段的值作为引用标题,而非自动生成的截断文本。

修改你代码中的fields_mapping部分:

"fields_mapping": {
    "title_field": "custom_title"  # 替换为索引中存储自定义标题的字段名
},

3. 直接更新Azure搜索索引中的标题

若数据已完成导入,可通过Azure搜索的SDK或REST API直接更新索引内文档的title字段值。示例代码如下:

from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient

search_client = SearchClient(
    endpoint=search_endpoint,
    index_name=search_index,
    credential=AzureKeyCredential(search_key)
)

# 更新单个文档的标题
updated_doc = {
    "id": "doc1",
    "title": "更新后的自定义标题"
}
search_client.upload_documents([updated_doc])

关于UI中title字段灰色的说明

UI中title字段呈灰色无法编辑,是因为默认状态下该字段由系统自动生成(基于文档内容截断)。通过上述方法自定义标题后,UI将显示你设置的标题值,后续可通过修改索引数据完成更新。

内容的提问来源于stack exchange,提问作者Franck Dernoncourt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 07:13:16