引用
Magisterium AI API 遵循 OpenAI API,响应对象中有一些附加字段。其中一个附加字段是 citations 字段。
json
{
"object": "chat.completion",
"created": 1630000000,
"model": "magisterium-1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "天主教会在信仰和道德方面的教义深深植根于圣经 [...]",
},
"finish_reason": "stop",
},
],
"citations": [
{
"cited_text": "34. 教会在道德问题上的教义不仅基于理性和论证,还基于圣经和基督教传统 [...]",
"document_title": "珍惜生命",
"document_index": 0,
"document_author": "英格兰和威尔士的天主教主教会议",
"document_reference": "34"
}
]
// other fields ...
}流媒体
当启用流媒体时,citations 字段也会包含在内,但仅在一个块中,即包含 finish_reason 的最后一块。
例如:
json
{
"object": "chat.completion.chunk",
"choices": [
{
"index": 0,
"delta": {},
"finish_reason": "stop",
},
],
"citations": [
{
"cited_text": "34. 教会在道德问题上的教义不仅基于理性和论证,还基于圣经和基督教传统 [...]",
"document_title": "珍惜生命",
"document_index": 0,
"document_author": "英格兰和威尔士的天主教主教会议",
"document_reference": "34"
}
]
// other fields ...
}模式
citations 字段是一个对象数组,具有以下字段:
| 字段名称 | 类型 | 描述 |
|---|---|---|
| cited_text | string | 被引用的文本。 |
| cited_text_heading | string / null | 给定引用的最近标题。 |
| document_title | string / null | 文档的标题。 |
| document_index | integer | 响应对象中文档的索引。索引为零基,内联脚注编号为一基。 |
| document_author | string / null | 文档的作者。 |
| document_year | string / null | 文档发布的年份。 |
| document_reference | string / null | 引用的参考编号。 |
| source_url | string | 文章来源 URL。 |