# 知識庫

<figure><img src="https://1593648278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmzb5NG9GDzFP2YDKeYVl%2Fuploads%2Fgit-blob-62364526efff5f143857970f6f8ccfb6fd96d246%2Fknowledge-base-infographic.png?alt=media" alt="知識庫概念"><figcaption><p>知識庫 RAG 流程：從文件上傳到 Agent 查閱回覆</p></figcaption></figure>

## 這是什麼？

知識庫是 Agent 的企業知識百科。你把公司的文件、FAQ、網頁內容放進知識庫，Agent 就能根據這些資料回答使用者的問題。

沒有知識庫的 Agent 只能靠語言模型的通用知識回覆。有了知識庫，它才能回答「我們公司的退貨政策是什麼？」這類企業專屬問題。

## 知識庫裡能放什麼？

| 資料類型     | 說明                   | 適合什麼情境         |
| -------- | -------------------- | -------------- |
| **文件上傳** | PDF、Word、Excel、TXT 等 | 產品手冊、內部規範、合約範本 |
| **FAQ**  | 問答對                  | 常見問題、標準回覆      |
| **爬蟲匯入** | 從網頁自動抓取內容            | 官網資訊、公開資料      |

## 跟資料庫有什麼不同？

這是最常被問到的問題：

|          | 知識庫              | 資料庫                |
| -------- | ---------------- | ------------------ |
| **資料型態** | 非結構化（文件、文章、FAQ）  | 結構化（表格、欄位、數字）      |
| **查詢方式** | 語意搜尋（「退貨政策是什麼？」） | SQL 查詢（「上個月營收多少？」） |
| **適合回答** | 知識性問題、政策規範、操作說明  | 數據查詢、統計分析、即時狀態     |

**簡單判斷**：如果答案在「文件」裡，用知識庫；如果答案在「報表」裡，用資料庫。

> **進階說明**：知識庫底層使用 RAG（Retrieval-Augmented Generation）技術。上傳的文件會被切割成段落、轉換為向量，當使用者提問時，系統會找出最相關的段落提供給 Agent 作為回覆依據。

## 我需要做什麼？

1. **建立知識庫** — 取名、選擇 Embedding 模型
2. **匯入資料** — 上傳文件、建立 FAQ、或使用爬蟲抓取
3. **搜尋測試** — 用模擬問題測試知識庫能不能找到正確答案
4. **掛載到 Agent** — 在 Agent 設定中連結這個知識庫

## 延伸閱讀

* [知識庫總覽](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/km/km.md)
* [如何建立知識庫：基本設置](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/km/km-basic-settings.md)
* [如何建立 FAQ 常見問題](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/km/faq.md)
* [文件管理：標籤及元資料](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/km/tags-and-metadata.md)
* [搜尋測試](https://github.com/Playma-Co-Ltd/maiagent-user-guide-gitbook/blob/main/zh-tw/km/test-search-result.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maiagent.ai/agent-builder/knowledge-base.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
