Files
aichat/README.en.md
T
2026-10-16 21:39:08 +08:00

341 lines
5.4 KiB
Markdown

# ChatAI
A modern AI chat client built with **Vue 3 + Vite + TypeScript + Element Plus**. It supports multi-model configuration, local config management, streaming responses, Markdown rendering, code highlighting, resend/regenerate actions, and more.
Suitable for:
- OpenAI-compatible chat APIs
- DeepSeek / Qwen / Moonshot / OpenRouter / local LLM gateway integration
- Personal AI toolbox
- Internal enterprise assistant frontend
- Model parameter debugging and testing
---
## 1. Project Purpose
ChatAI is a general-purpose frontend AI chat application designed to be:
- Clean and easy to use
- Flexible in model configuration
- Friendly to streaming responses
- Capable of Markdown and code rendering
- Suitable for switching between multiple saved model presets
- Easy to extend for secondary development
You can use it as:
1. A ready-to-use AI chat UI
2. An OpenAI-compatible API debugging client
3. A frontend foundation for internal AI assistant systems
---
## 2. Tech Stack
### Frontend
- **Vue 3**
- **TypeScript**
- **Vite**
### UI / Interaction
- **Element Plus**
- **@element-plus/icons-vue**
- **Sass / SCSS**
### State / Routing
- **Pinia**
- **Vue Router**
### Content Rendering
- **markdown-it**
- **highlight.js**
- **clipboard-copy**
---
## 3. Features
### Chat Features
- Standard chat conversation
- Streaming output
- Stop generation
- Delete single messages
- Resend user messages
- Regenerate assistant replies
- Clear current session
### Markdown Features
- Markdown rendering
- Syntax highlighted code blocks
- Copy code support
- Basic tables, lists, blockquotes
- Partial automatic detection of code / SQL / JSON blocks
### Configuration Features
- BaseURL
- API Key
- Model name
- Temperature
- max_tokens
- Context rounds
- Stream toggle
- System prompt
- Save current config
- Save as new config
- Rename / delete config
- Fast switch between configs
- Auto-save to browser local storage
---
## 4. Project Structure
```text README.en.md
.
├─ src
│ ├─ components
│ ├─ services
│ ├─ stores
│ ├─ utils
│ ├─ views
│ ├─ constants
│ └─ types
├─ public
├─ package.json
└─ vite.config.*
```
---
## 5. Requirements
Recommended environment:
- **Node.js >= 18**
- **npm >= 9** or **pnpm >= 8**
Check versions:
```bash README.en.md
node -v
npm -v
```
---
## 6. Install and Run
### 6.1 Clone the project
```bash README.en.md
git clone <your-repository-url>
cd <project-folder>
```
### 6.2 Install dependencies
Using npm:
```bash README.en.md
npm install
```
Using pnpm:
```bash README.en.md
pnpm install
```
### 6.3 Start development server
```bash README.en.md
npm run dev
```
Then open the local URL in your browser, for example:
```text README.en.md
http://localhost:5173/
```
---
## 7. Build and Preview
### 7.1 Build for production
```bash README.en.md
npm run build
```
Output directory:
```text README.en.md
dist/
```
### 7.2 Preview build output
```bash README.en.md
npm run preview
```
### 7.3 Type check
```bash README.en.md
npm run type-check
```
---
## 8. Deployment
This is a static frontend project. The `dist` folder can be deployed to:
- Nginx
- Apache
- Vercel
- Netlify
- Gitee Pages
- GitHub Pages
- Any static hosting service
### 8.1 Nginx example
```nginx README.en.md
server {
listen 80;
server_name your-domain.com;
root /path/to/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
```
---
## 9. Model Configuration
### 9.1 BaseURL
The base API address of the model service.
Examples:
```text README.en.md
https://api.openai.com
https://api.deepseek.com
http://127.0.0.1:11434
```
### 9.2 API Key
Authentication token used to access the model provider.
### 9.3 Model Name
The real model identifier sent in API requests.
Examples:
```text README.en.md
gpt-4o-mini
gpt-4.1
deepseek-chat
qwen-plus
```
### 9.4 Temperature
Controls randomness:
- Lower = more stable
- Higher = more creative
Common suggestions:
- Code / SQL: `0.2`
- General QA: `0.7`
- Creative writing: `1.0`
### 9.5 max_tokens
Controls maximum output length.
### 9.6 Context Rounds
Controls how much previous conversation history is sent with the current request.
### 9.7 Stream Output
When enabled, the UI displays the response progressively.
### 9.8 System Prompt
Used to define role, style, and behavior rules for the assistant.
---
## 10. Recommended Production Architecture
For personal local use, direct frontend access may be acceptable.
For real production use, the recommended architecture is:
```text README.en.md
Frontend -> Your Backend Proxy -> Model Provider
```
Benefits:
- Hide the real API key
- Centralized permission control
- Logging and audit support
- Rate limiting and billing control
---
## 11. Useful Scripts
```bash README.en.md
npm run dev
npm run build
npm run preview
npm run type-check
```
---
## 12. Security Notes
This project currently stores configuration in the browser and may directly call model APIs.
Please note:
1. API keys may be exposed to the browser environment
2. This is not ideal for high-security production use
3. A backend proxy is strongly recommended for enterprise usage
---
## 13. Contribution
Contributions are welcome.
Suggested workflow:
1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Open a Pull Request
---
## 14. License
If no dedicated license file is provided, please add one according to your project needs.
Common choices:
- MIT
- Apache-2.0
- GPL-3.0