# AI Overview

## Page Guide

- **Scenario**: Understand the relationship between models, chat, knowledge bases, protocol adaptation, and intelligent queries before enabling AI features.
- **Prerequisite**: The backend version includes `fastbee-ai`, and the Vue3 console can open AI menus.
- **Acceptance**: Models are available, knowledge can be retrieved, chat returns answers, and protocol or data-query tasks enter the AI flow.

## 1. Capability Structure

```mermaid
%%{init: {"flowchart": {"htmlLabels": false}}}%%
flowchart LR
  A["Model provider"] --> B["Model configuration"]
  B --> C["AI chat"]
  B --> D["Knowledge base / RAG"]
  D --> E["Document parsing"]
  E --> F["Version build"]
  F --> G["Publish / rollback"]
  D --> H["Protocol adaptation"]
  B --> I["NL2SQL"]
  I --> J["Realtime / time-series / mixed query"]
```

## 2. Menu And Source Mapping

| Feature | Frontend Directory | Backend Prefix | Description |
| --- | --- | --- | --- |
| AI Chat | `vue3/src/views/ai/chat` | `/ai/chat` | User question and model response. |
| Chat Records | `vue3/src/views/ai/chatRecord` | `/ai/chatRecord` | Query and manage chat history. |
| Model Provider | `vue3/src/views/ai/provider` | `/ai/provider` | Provider, key, and availability. |
| Model Configuration | `vue3/src/views/ai/model` | `/ai/model` | Model name, type, parameter, and status. |
| Knowledge Base | `vue3/src/views/ai/knowledge` | `/ai/knowledge` | Upload, parse, version, and publish documents. |
| Protocol Adaptation | `vue3/src/views/ai/protocolAdaptation` | `/ai/protocol/adaptation` | Analyze protocol materials and generate access suggestions. |
| NL2SQL | Integrated by page | `/ai/nl2sql` | Convert natural language into structured query plans. |

## 3. Recommended Configuration Order

1. Configure a model provider.
2. Configure and enable a model.
3. Test AI chat with a simple question.
4. Create a knowledge base and upload documents.
5. Parse documents, build a version, and publish it.
6. Use the knowledge base in protocol adaptation or business Q\&A.
7. Configure NL2SQL only after data permission and semantic fields are clear.

## 4. Typical Scenarios

| Scenario | Required Setup | Output |
| --- | --- | --- |
| Document Q\&A | Model, knowledge base, documents, published version. | Users can ask questions about platform or project documents. |
| Protocol adaptation | Model, protocol knowledge, protocol materials. | Field explanation, access suggestions, and development notes. |
| Operations assistant | Model, platform knowledge, issue collection. | Assist troubleshooting for access, deployment, video, and operations. |
| Data query | Model, semantic model, data permission. | Query plan or SQL-like result. |
| Source-code knowledge | Model and source-code materials. | Help developers understand modules and APIs. |

## 5. Security Notes

* API keys and model secrets should be maintained only by administrators.
* Knowledge-base documents may contain customer data and should be desensitized when needed.
* AI-generated access suggestions must be verified with real device messages.
* NL2SQL must be constrained by data permission to avoid unauthorized queries.

## Related Docs

* [Model Provider](https://www.fastbee.cn/doc/en/business/v2/manual/ai-provider.html)
* [Knowledge Base And RAG](https://www.fastbee.cn/doc/en/business/v2/manual/ai-knowledge.html)
* [Protocol Adaptation](https://www.fastbee.cn/doc/en/business/v2/manual/ai-protocol-adaptation.html)
* [AI Development](https://www.fastbee.cn/doc/en/business/v2/dev/ai-development.html)
