---
title: "带引用回答的客服知识库"
description: "将帮助文章存为文件，取得标明所用文章及版本的回答；依据不足时放弃回答。"
url: https://mirabase.io/zh/use-cases/support-knowledge-base
last_updated: 2026-11-26
lang: zh-CN
---

# 带引用回答的客服知识库

将帮助文章存为文件，再通过回答接口提问。每个回答都引用所用的文件，带路径和版本；依据不足时放弃回答，不作猜测。

## 示例

安装 SDK（`npm install @mirabase/sdk` 或 `pip install mirabase`），并设置 `MIRABASE_API_KEY`。

```ts
import { Mirabase } from "@mirabase/sdk";

const mb = new Mirabase(); // reads MIRABASE_API_KEY

// waitSeconds holds the response for up to 10 seconds, until the file is indexed.
await mb.files.write("/help/refunds.md", "# Refunds\n\nRefunds are issued within 14 days of purchase.\n", {
  contentType: "text/markdown",
  waitSeconds: 10,
});

const reply = await mb.answer("How long do customers have to ask for a refund?");
if (reply.status === "answered") console.log(reply.answer, reply.citations);
else console.log("abstained:", reply.reason);
```

```python
from mirabase import Mirabase

mb = Mirabase()  # reads MIRABASE_API_KEY

# wait_seconds holds the response for up to 10 seconds, until the file is indexed.
mb.files.write(
    "/help/refunds.md",
    "# Refunds\n\nRefunds are issued within 14 days of purchase.\n",
    content_type="text/markdown",
    wait_seconds=10,
)

reply = mb.answer("How long do customers have to ask for a refund?")
if reply["status"] == "answered":
    print(reply["answer"], reply["citations"])
else:
    print("abstained:", reply.get("reason"))
```

引用带有文件的 `path`、`entry_id`、`version_id` 以及所依据的段落。如需使用自己的模型，改为调用 `mb.context(...)`，在 token 预算内取得一组来源。详见 [检索与上下文](https://mirabase.io/zh/developers/retrieval)。

## 边界

- 回答需要 `knowledge:answer` 能力，并计入套餐的每月模型用量。
- 写入返回后，文件在后台处理。建立索引之前，检索只能按词语找到较短的文本文件。详见 [处理进度](https://mirabase.io/zh/developers/processing)。
- 单次写入最多 16 MiB，更大的文件使用分片上传；大量小文件可使用批量写入，见 [批量写入](https://mirabase.io/zh/developers/files#batch)。
- 未指定 Space 时，回答会读取该 Key 可读的所有 Space。请把每个客户的资料放在各自的 Space 中并在调用时指定，或签发限定到该 Space 的 Key。
- 更新文章时写入同一路径即可。旧版本会保留，引用会标明所用的版本。
