引用
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。 |