��������������������������������������������������������������������
�? �?
�? �� AI Robot - Intelligent Group Chat Assistant �� �?
�? �?
�? �箄蝢方��拇� - Smart QQ/WeChat Group Chat AI Bot �?
�? �?
��������������������������������������������������������������������
�� Plug-and-Play QQ Group AI Bot | Multi-Platform API Support | One-Click Launch | Ready to Use
- Project Overview
- Architecture
- Features
- System Requirements
- Installation
- Quick Start Guide
- Configuration
- Protocol Documentation
- Advanced Usage
- Troubleshooting
- Contributing
- License
- Changelog
AI Robot is a sophisticated, production-ready intelligent group chat assistant designed for QQ and WeChat platforms. Built with modern technologies (Electron, Vue 3, TypeScript), it provides seamless AI-powered conversations with support for multiple LLM providers.
| Feature | Description |
|---|---|
| � Zero-Configuration | Download �?Install �?API Key �?Launch |
| �� Multi-Platform AI | Alibaba Cloud, DeepSeek, Zhipu, Moonshot, OpenAI, Google, Ollama |
| � Smart Conversations | @ mentions, command triggers, auto-reply in private chats |
| �儭?Vision Support | Image recognition with multimodal AI (Pro version) |
| � Voice Reply | Text-to-speech responses (Pro version) |
| �� Plugin System | Extensible plugin architecture |
| � Session Persistence | SQLite storage, survives restarts |
| � Modern UI | Electron + Vue 3, smooth and beautiful |
| �� Dark Theme | Eye-friendly dark interface |
AI Robot follows a modular, adapter-based architecture that separates concerns and enables easy extensibility.
�����������������������������������������������������������������������������������������������������������������������������������?
�? AI Robot �?
�����������������������������������������������������������������������������������������������������������������������������������?
�? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �? QQ Adapter �? �?IM Adapters �? �?WeChat �? �?
�? �? (NapCatQQ) �? �? (Platform) �? �?(Future) �? �?
�? �������������砂������������? �������������砂������������? �������������砂������������? �?
�? �? �? �? �?
�? �������������������������������������潑������������������������������������? �?
�? �? �?
�? �����������������������������������? �?
�? �? Core Layer �? �?
�? �? - IM Handler �? �?
�? �? - LLM Selector �? �?
�? �? - Storage �? �?
�? �? - Plugin �? �?
�? �����������������砂����������������? �?
�? �? �?
�? �������������������������������������潑������������������������������������? �?
�? �? �? �? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �?Alibaba �? �?Ollama �? �?Future �? �?
�? �?Adapter �? �?Adapter �? �?Providers �? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �?
�? ���������������������������? ���������������������������? �?
�? �? Setup UI �? �? SQLite �? �?
�? �? (Console) �? �? Storage �? �?
�? ���������������������������? ���������������������������? �?
�? �?
�����������������������������������������������������������������������������������������������������������������������������������?
| Component | Location | Responsibility |
|---|---|---|
| apps/server | apps/server/ |
Main service entry, HTTP/WebSocket server, component initialization |
| apps/setup-ui | apps/setup-ui/ |
Visual console, environment detection, configuration wizard |
| packages/core | packages/core/ |
Core logic: IM handling, LLM routing, storage, plugins |
| packages/qq-adapter | packages/qq-adapter/ |
NapCatQQ WebSocket integration |
| packages/wechat-adapter | packages/wechat-adapter/ |
WeChat HTTP adapter (reserved) |
| packages/alibaba-adapter | packages/alibaba-adapter/ |
Alibaba Cloud/DashScope API |
| packages/ollama-adapter | packages/ollama-adapter/ |
Local Ollama model integration |
| packages/sqlite-storage | packages/sqlite-storage/ |
SQLite session persistence |
| packages/doctor | packages/doctor/ |
Environment diagnostics |
| Capability | Description | Status |
|---|---|---|
| Multi-turn Conversation | Context-aware dialogue with session memory | �? |
| System Prompts | Customizable AI personality and behavior | �? |
| Temperature Control | Adjust response creativity | �? |
| Token Limits | Configure max response length | �? |
| Vision (Multimodal) | Image understanding and description | �� Pro |
| Voice Synthesis | Text-to-speech responses | �� Pro |
| Feature | Description |
|---|---|
| @ Mention Trigger | Bot responds when mentioned in groups |
| Command Prefix | Use /ai or custom prefix to trigger |
| Private Auto-Reply | Automatic responses in private chats |
| Group Smart Reply | Intelligent group conversation handling |
| Message Quoting | Reply to specific messages |
| Option | Type | Default | Description |
|---|---|---|---|
LLM_PROVIDER |
string | alibaba |
AI provider selection |
ALIBABA_API_KEY |
string | - | Alibaba Cloud API key |
ALIBABA_MODEL |
string | qwen-plus |
Model selection |
OLLAMA_BASE_URL |
string | http://localhost:11434 |
Ollama server URL |
SESSION_STORAGE |
string | sqlite |
Storage backend |
SESSION_MAX_MESSAGES |
number | 100 |
Max messages per session |
CHAT_PREFIX |
string | /ai |
Command trigger prefix |
PRIVATE_AUTO_REPLY |
boolean | true |
Auto-reply in private chats |
GROUP_AI_TRIGGER |
string | both |
Group trigger mode: at, prefix, both |
| Platform | Requirement |
|---|---|
| Windows | Windows 10 64-bit |
| macOS | macOS 10.15 (Catalina) |
| Linux | Ubuntu 20.04 LTS |
| Platform | Recommendation |
|---|---|
| Windows | Windows 11 64-bit |
| macOS | macOS 12+ (Monterey) |
| Linux | Ubuntu 22.04 LTS |
| Software | Version | Required For |
|---|---|---|
| Node.js | 18.0.0+ | Source build |
| pnpm | 8.0.0+ | Source build |
| NapCatQQ | Latest | QQ integration |
| Ollama | Latest | Local models (optional) |
- Visit the Releases page
- Download the installer for your platform
- Install and launch the application
- Select your AI platform and enter your API Key
- Start NapCatQQ and scan QR code to login
- Click "Start Bot" to begin
# Clone repository
git clone https://github.com/badhope/ai-robot.git
cd ai-robot
# Install dependencies
pnpm install
# Development mode
pnpm dev
# Build for production
pnpm build:win # Windows
pnpm build:mac # macOS
pnpm build:linux # Linux# Build image
docker build -t ai-robot .
# Configure environment
cp .env.example .env
# Edit .env with your API keys
# Run container
cd deployments
docker-compose up -d�� How to obtain API keys
Alibaba Cloud (Recommended)
- Visit Alibaba Cloud Bailian
- Login or register an account
- Enable DashScope service
- Navigate to "API-KEY Management" �?"Create API Key"
DeepSeek
- Visit DeepSeek Platform
- Register an account
- Go to "API Keys" �?"Create API Key"
Zhipu AI
- Visit Zhipu Open Platform
- Register an account
- Go to "API Keys" �?"Add API Key"
OpenAI
- Visit OpenAI Platform
- Create an account
- Generate an API key from the dashboard
�� NapCatQQ Setup Guide
- Download NapCatQQ
- Extract and run the application
- Scan QR code with your bot QQ account
- Ensure WebSocket port is set to
3001
For detailed instructions, see NapCatQQ Guide
# Run the application
pnpm dev
# Or use the desktop app
# Simply click "Start Bot" in the UIIn a QQ group:
@YourBot Hello, how are you?
Or use the command prefix:
/ai What's the weather today?
Create a .env file in the project root:
# ====================
# Server Configuration
# ====================
APP_HOST=0.0.0.0
APP_PORT=3000
# ====================
# QQ Configuration
# ====================
QQ_ENABLED=true
QQ_HTTP_PORT=3001
QQ_WS_URL=ws://localhost:3001
QQ_NUMBER=123456789
QQ_TOKEN=
# ====================
# AI Provider Configuration
# ====================
LLM_PROVIDER=alibaba
# Alibaba Cloud (Default)
ALIBABA_API_KEY=your-api-key-here
ALIBABA_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
ALIBABA_MODEL=qwen-plus
ALIBABA_TIMEOUT=120000
# Ollama (Local Mode)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5:7b
OLLAMA_TIMEOUT=120000
# ====================
# Session Storage
# ====================
SESSION_STORAGE=sqlite
SQLITE_DB_PATH=./data/sessions.db
SESSION_MAX_MESSAGES=100
# ====================
# Trigger Rules
# ====================
CHAT_PREFIX=/ai
PRIVATE_AUTO_REPLY=true
GROUP_AI_TRIGGER=both
# ====================
# Logging
# ====================
LOG_LEVEL=info| Platform | Features | Free Tier | Rating |
|---|---|---|---|
| �� Alibaba Cloud | Fast, stable | Yes | 潃�潃�潃? |
| �� DeepSeek | Cost-effective | Yes | 潃�潃�潃? |
| �� Zhipu AI | Chinese LLM | Yes | 潃�潃� |
| �� Moonshot | Long context | Yes | 潃�潃� |
| �� OpenAI | GPT-4 | Limited | 潃�潃� |
| �� Google Gemini | Large free tier | Yes | 潃�潃� |
| � Local Ollama | Completely free | Unlimited | 潃�潃?(GPU required) |
AI Robot implements multiple protocols for communication between components, external services, and messaging platforms. This section documents all protocols used in the system.
The IM (Instant Messaging) Platform Protocol defines the standard interface for integrating different messaging platforms (QQ, WeChat, etc.) into AI Robot.
interface IMAdapter {
name: string;
platform: 'wechat' | 'qq' | 'mock';
start(): Promise<void>;
stop(): Promise<void>;
sendReply(event: ChatMessageEvent, reply: ChatReply): Promise<void>;
onMessage(handler: (event: ChatMessageEvent) => Promise<void>): void;
}interface ChatMessageEvent {
platform: Platform;
chatType: 'private' | 'group';
messageId: string;
senderId: string;
senderName?: string;
roomId?: string;
roomName?: string;
text: string;
mentions?: string[];
isAt?: boolean;
replyToMessageId?: string;
timestamp: number;
raw?: unknown;
}interface ChatReply {
text: string;
replyToMessageId?: string;
}| Adapter | Protocol | Transport | Port |
|---|---|---|---|
| NapCatQQ | WebSocket | WS | 3001 |
| HTTP | REST | Configurable |
import { NapCatQQAdapter } from '@ai-robot/qq-adapter';
const adapter = new NapCatQQAdapter({
httpPort: 3001,
wsUrl: 'ws://localhost:3001',
qqNumber: '123456789',
});
await adapter.start();
adapter.onMessage(async (event) => {
console.log(`Message from ${event.senderName}: ${event.text}`);
await adapter.sendReply(event, { text: 'Hello!' });
});The LLM (Large Language Model) Provider Protocol defines the standard interface for integrating different AI providers into AI Robot.
interface LLMProvider {
name: string;
kind: 'local' | 'remote' | 'experimental';
generate(input: LLMGenerateRequest): Promise<LLMGenerateResponse>;
healthCheck(): Promise<boolean>;
listModels?(): Promise<string[]>;
}interface LLMGenerateRequest {
model?: string;
systemPrompt?: string;
messages: Array<{
role: 'system' | 'user' | 'assistant';
content: string;
}>;
temperature?: number;
topP?: number;
maxTokens?: number;
metadata?: Record<string, unknown>;
}interface LLMGenerateResponse {
provider: string;
model: string;
content: string;
usage?: {
promptTokens?: number;
completionTokens?: number;
totalTokens?: number;
};
raw?: unknown;
}| Provider | Kind | API Endpoint | Authentication |
|---|---|---|---|
| Alibaba Cloud | remote | dashscope.aliyuncs.com |
Bearer Token |
| Ollama | local | localhost:11434 |
None |
| OpenAI | remote | api.openai.com |
Bearer Token |
| DeepSeek | remote | api.deepseek.com |
Bearer Token |
import { AlibabaProvider } from '@ai-robot/alibaba-adapter';
const provider = new AlibabaProvider({
apiKey: 'sk-xxx',
model: 'qwen-plus',
});
const response = await provider.generate({
messages: [
{ role: 'user', content: 'Hello!' }
],
temperature: 0.7,
});
console.log(response.content);NapCatQQ uses WebSocket for real-time bidirectional communication between the QQ client and AI Robot.
| Parameter | Value |
|---|---|
| Protocol | WebSocket |
| Default URL | ws://localhost:3001 |
| Message Format | JSON |
| Encoding | UTF-8 |
Incoming Message (from NapCatQQ)
{
"post_type": "message",
"message_type": "group",
"sub_type": "normal",
"user_id": 123456789,
"group_id": 987654321,
"group_name": "Test Group",
"sender": {
"nickname": "User",
"card": "Card Name"
},
"message_id": 12345,
"message": [
{ "type": "text", "text": "Hello" },
{ "type": "at", "data": { "qq": 987654321 } }
],
"raw_message": "Hello @bot",
"time": 1234567890
}Outgoing Message (to NapCatQQ)
{
"message_type": "group",
"group_id": 987654321,
"message": "Reply text here"
}| Parameter | Value |
|---|---|
| Max Attempts | 10 |
| Base Delay | 1000ms |
| Max Delay | 30000ms |
| Backoff | Exponential |
Alibaba Cloud DashScope API provides access to Qwen series language models.
| Environment | URL |
|---|---|
| Production | https://dashscope.aliyuncs.com/compatible-mode/v1 |
| Chat Completions | /chat/completions |
Authorization: Bearer sk-xxxxxxxxxxxxxxxx
Content-Type: application/json{
"model": "qwen-plus",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"temperature": 0.7,
"max_tokens": 2048
}{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1234567890,
"model": "qwen-plus",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}| Model | Context | Description |
|---|---|---|
qwen-turbo |
8K | Fast, cost-effective |
qwen-plus |
32K | Balanced performance |
qwen-max |
32K | Best quality |
qwen-long |
1M | Long context |
Ollama provides a local REST API for running open-source language models.
| Endpoint | URL |
|---|---|
| Base URL | http://localhost:11434 |
| Chat API | /api/chat |
| Models List | /api/tags |
{
"model": "qwen2.5:7b",
"messages": [
{ "role": "user", "content": "Hello!" }
],
"stream": false,
"options": {
"temperature": 0.7,
"top_p": 0.9,
"num_predict": 512
}
}{
"model": "qwen2.5:7b",
"created_at": "2024-01-01T00:00:00Z",
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"done": true,
"total_duration": 1000000000,
"prompt_eval_count": 10,
"eval_count": 20
}The Session Storage Protocol defines how conversation history is persisted and retrieved.
interface SessionStore {
getSession(sessionId: string): Promise<SessionMessage[]>;
appendMessage(sessionId: string, message: SessionMessage): Promise<void>;
clearSession(sessionId: string): Promise<void>;
}interface SessionMessage {
role: 'system' | 'user' | 'assistant';
content: string;
timestamp?: number;
}CREATE TABLE sessions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT NOT NULL,
role TEXT NOT NULL,
content TEXT NOT NULL,
timestamp INTEGER NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now'))
);
CREATE INDEX idx_session_id ON sessions(session_id);
CREATE INDEX idx_timestamp ON sessions(session_id, timestamp);import { SQLiteSessionStore } from '@ai-robot/sqlite-storage';
const store = new SQLiteSessionStore({
dbPath: './data/sessions.db',
maxMessages: 100,
});
// Get session history
const messages = await store.getSession('group_123456');
// Append message
await store.appendMessage('group_123456', {
role: 'user',
content: 'Hello!',
timestamp: Date.now(),
});The HTTP API provides REST endpoints for external integrations and the setup UI.
| Method | Path | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/send |
Send message |
GET |
/status |
Bot status |
POST /send HTTP/1.1
Content-Type: application/json
{
"message_type": "group",
"group_id": 123456789,
"message": "Hello from HTTP API"
}The Plugin Protocol enables extensibility through custom message processors.
interface Plugin {
name: string;
priority: number;
process(event: ChatMessageEvent, context: PluginContext): Promise<PluginResult | null>;
}
interface PluginContext {
provider: LLMProvider;
storage: SessionStore;
config: Record<string, unknown>;
}
interface PluginResult {
handled: boolean;
reply?: string;
}Create custom prompts in the prompts/ directory:
prompts/
���� default/
�? ���� friendly.txt
�? ���� tech-expert.txt
���� group/
�? ���� active.txt
�? ���� concise.txt
���� helper/
���� assistant.txt
// In configuration
LLM_PROVIDER=ollama // Switch to local model
OLLAMA_MODEL=llama3:8b# Only respond to @ mentions
GROUP_AI_TRIGGER=at
# Only respond to prefix commands
GROUP_AI_TRIGGER=prefix
# Respond to both (default)
GROUP_AI_TRIGGER=bothpnpm doctorThis checks:
- Node.js version
- Configuration files
- API connectivity
- NapCatQQ connection
- SQLite status
� Bot not responding
- Verify NapCatQQ is running
- Check WebSocket connection (
ws://localhost:3001) - Ensure
QQ_ENABLED=truein.env - Verify API key is configured
- Check bot is mentioned correctly with
@
� API connection failed
- Verify API key is correct
- Check account has available credits
- Test network connectivity:
ping dashscope.aliyuncs.com - Verify base URL is correct
� SQLite errors
- Check directory permissions
- Verify disk space available
- Delete and recreate database:
rm data/sessions.db
� Ollama connection issues
- Verify Ollama is installed:
ollama --version - Check Ollama service:
ollama serve - Verify model is downloaded:
ollama list - Check configuration:
LLM_PROVIDER=ollama OLLAMA_BASE_URL=http://localhost:11434
| Error | Meaning | Solution |
|---|---|---|
401 Unauthorized |
Invalid API key | Check API key configuration |
Connection refused |
Service not running | Start the required service |
WebSocket closed |
NapCatQQ disconnected | Restart NapCatQQ |
Model not found |
Model doesn't exist | Download model or check name |
Out of credit |
Insufficient balance | Add credits to account |
We welcome all contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/AmazingFeature - Make your changes
- Run tests:
pnpm test - Commit:
git commit -m 'Add AmazingFeature' - Push:
git push origin feature/AmazingFeature - Open a Pull Request
# Install dependencies
pnpm install
# Run in development
pnpm dev
# Run linter
pnpm lint
# Type check
pnpm typecheck
# Build
pnpm build- Use TypeScript for all new code
- Follow existing code conventions
- Add appropriate comments
- Update documentation
See CONTRIBUTING.md for detailed guidelines.
This project uses a dual-license model:
| Component | License |
|---|---|
| Open Source Parts | MIT License |
| Commercial Parts | Commercial License |
See LICENSE for details.
See CHANGELOG.md for version history.
[2.0.0] - 2024-03-26
- �� New Electron desktop application architecture
- � Vue 3 + TypeScript modern UI
- �� Star theme UI design
- � Simple and Expert mode toggle
- � Visual configuration wizard
- �� Multi-platform AI API support
- � Local Ollama model support
- �� Plugin system architecture
- �� Pro version features
- �� Conversation statistics
- �� Dark theme support
| Channel | Link |
|---|---|
| contact@ai-robot.dev | |
| � QQ Group | 123456789 |
| �� Website | https://ai-robot.dev |
| �� Documentation | https://docs.ai-robot.dev |
| �� Issues | GitHub Issues |
- 憿寧璁膩
- 蝟餌��嗆�
- [��寞�吞(#��寞�?
- 蝟餌�閬�
- 摰���
- [敹恍��憪(#敹恍��憪?
- �蔭霂湔�
- �悅�﹝
- 擃漣�冽�
- ���
- 韐∠��
- [撘�皞�霈孫(#撘�皞�霈?
- �湔�亙�
AI Robot �臭�銝芣�����鈭批停蝏芰��箄蝢方��拇�嚗�銝?QQ �凝靽∪像�啗挽霈~�鈭隞���舀�嚗lectron�ue 3�ypeScript嚗�撱綽���瘚��?AI 撖寡�雿�嚗��蝘之霂剛�璅∪�����?
| �寞�? | �膩 |
|---|---|
| � *�餌�撘�雿? | 銝蝸 �?摰� �?憛怠� API Key �?銝��桀�? |
| �� *憭像�唳�? | �輸�鈭�eepSeek�靚晞��銋��U�penAI�oogle��?Ollama |
| � �箄撖寡� | �舀� @ 閫血��隞方圻�����典�憭? |
| �儭?�曄�霂 | 霂�曄��捆嚗�璅⊥�?AI �舀�嚗�銝�嚗? |
| � 霂剝�� | ��頧祈祗�喳�憭�銝��� |
| �� �辣蝟餌� | 銝啣���隞嗥����舀撅��? |
| � *隡����? | SQLite 摮嚗��臭�銝W仃 |
| � �唬誨� | Electron + Vue 3嚗���閫? |
| �� �銝駁� | �斤�楛�脩��? |
AI Robot �璅∪������冽芋撘��嗆�嚗��啣瘜函�氖��鈭撅�?
�����������������������������������������������������������������������������������������������������������������������������������?
�? AI Robot �?
�����������������������������������������������������������������������������������������������������������������������������������?
�? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �? QQ ���? �? �?IM ���? �? �?敺桐縑���? �? �?
�? �? (NapCatQQ) �? �? (撟喳) �? �?(憸�) �? �?
�? �������������砂������������? �������������砂������������? �������������砂������������? �?
�? �? �? �? �?
�? �������������������������������������潑������������������������������������? �?
�? �? �?
�? �����������������������������������? �?
�? �? �詨�撅? �? �?
�? �? - IM 憭��? �? �?
�? �? - LLM ��? �? �?
�? �? - 摮撅? �? �?
�? �? - �辣蝟餌� �? �?
�? �����������������砂����������������? �?
�? �? �?
�? �������������������������������������潑������������������������������������? �?
�? �? �? �? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �?�輸�鈭? �? �?Ollama �? �?�芣 �? �?
�? �?���? �? �?���? �? �?���? �? �?
�? ���������������������������? ���������������������������? ���������������������������? �?
�? �?
�? ���������������������������? ���������������������������? �?
�? �? 霈曄蔭� �? �? SQLite �? �?
�? �? (�批�? �? �? 摮 �? �?
�? ���������������������������? ���������������������������? �?
�? �?
�����������������������������������������������������������������������������������������������������������������������������������?
| 蝏辣 | 雿蔭 | �提 |
|---|---|---|
| apps/server | apps/server/ |
銝餅��∪���HTTP/WebSocket �嚗�隞嗅�憪� |
| apps/setup-ui | apps/setup-ui/ |
�航���嗅嚗憓�瘚��蔭�紡 |
| packages/core | packages/core/ |
�詨��餉�嚗M 憭�嚗LM 頝舐嚗��剁��辣 |
| packages/qq-adapter | packages/qq-adapter/ |
NapCatQQ WebSocket �� |
| packages/wechat-adapter | packages/wechat-adapter/ |
敺桐縑 HTTP ���剁�憸�嚗? |
| packages/alibaba-adapter | packages/alibaba-adapter/ |
�輸�鈭?DashScope API |
| packages/ollama-adapter | packages/ollama-adapter/ |
�砍 Ollama 璅∪��� |
| packages/sqlite-storage | packages/sqlite-storage/ |
SQLite 隡����? |
| packages/doctor | packages/doctor/ |
�臬�霂 |
| �賢� | �膩 | �嗆�? |
|---|---|---|
| 憭蔭撖寡� | 銝����亦�撖寡�嚗蒂隡�霈啣� | �? |
| 蝟餌��內霂? | �航摰� AI 鈭箸��銝? | �? |
| 皜拙漲�批 | 靚�����? | �? |
| Token � | �蔭��憭批�憭摨? | �? |
| 閫�嚗�璅⊥�� | �曉��圾��餈? | �� 銝��? |
| 霂剝�� | ��頧祈祗�喳�憭? | �� 銝��? |
| � | �膩 |
|---|---|
| @ ��閫血� | 蝢方�銝剛◤ @ �嗅�摨? |
| �賭誘�� | 雿輻 /ai �摰���閫血� |
| 蝘��芸�� | 蝘�銝剛�典�摨? |
| 蝢方��箄�� | �箄蝢方�撖寡�憭� |
| 瘨撘 | ���孵�瘨 |
| 撟喳 | 閬� |
|---|---|
| Windows | Windows 10 64 雿? |
| macOS | macOS 10.15 (Catalina) |
| Linux | Ubuntu 20.04 LTS |
| 撟喳 | �刻� |
|---|---|
| Windows | Windows 11 64 雿? |
| macOS | macOS 12+ (Monterey) |
| Linux | Ubuntu 22.04 LTS |
| 頧臭辣 | � | �券�? |
|---|---|---|
| Node.js | 18.0.0+ | 皞��遣 |
| pnpm | 8.0.0+ | 皞��遣 |
| NapCatQQ | ���啁� | QQ �� |
| Ollama | ���啁� | �砍璅∪�嚗�� |
- �� Releases 憿菟
- 銝蝸撖孵�撟喳��鋆�
- 摰�撟嗅�典��?
- � AI 撟喳嚗‵�?API Key
- �臬 NapCatQQ 撟嗆�敶?
- �孵��冽�其犖��憪蝙�?
# ��隞�
git clone https://github.com/badhope/ai-robot.git
cd ai-robot
# 摰�靘�
pnpm install
# 撘��芋撘?
pnpm dev
# �遣�漣�
pnpm build:win # Windows
pnpm build:mac # macOS
pnpm build:linux # Linux# �遣��
docker build -t ai-robot .
# �蔭�臬�
cp .env.example .env
# 蝻� .env 憛怠 API 撖
# 餈�摰孵
cd deployments
docker-compose up -d�� 憒��瑕� API Key
*�輸�鈭��刻�嚗?
- �� [�輸�鈭�奭(https://bailian.console.aliyun.com/)
- �餃�/瘜典��輸�鈭揭�?
- 撘��?DashScope �
- �孵撌虫儒�PI-KEY 蝞∠�����撱?API Key�?
DeepSeek
- �� DeepSeek 摰�
- 瘜典�韐血
- 餈�PI Keys����撱?API Key�?
�箄停 AI
- �� [�箄停撘��曉像�財(https://open.bigmodel.cn/)
- 瘜典�韐血
- 餈�PI 撖���溶�?API 撖�?
�� NapCatQQ 霈曄蔭��
- 銝蝸 NapCatQQ
- 閫��撟嗉�銵?
- �怎��餃�雿� QQ �箏鈭箄揭�?
- 蝖桐� WebSocket 蝡臬銝?3001
霂衣���霂瑟�?NapCatQQ 雿輻��
# 餈�摨
pnpm dev
# �蝙�冽��W��?
# �函��V葉�孵��冽�其犖�?�?QQ 蝢支葉嚗?
@雿��箏鈭?雿末嚗�憭拙予瘞���瘀�
�蝙�典隞文�蝻�嚗?
/ai 隞予憭拇����瘀�
�券★�格�桀��遣 .env �辣嚗?
# ====================
# ��券�蝵?
# ====================
APP_HOST=0.0.0.0
APP_PORT=3000
# ====================
# QQ �蔭
# ====================
QQ_ENABLED=true
QQ_HTTP_PORT=3001
QQ_WS_URL=ws://localhost:3001
QQ_NUMBER=123456789
QQ_TOKEN=
# ====================
# AI ����蝵?
# ====================
LLM_PROVIDER=alibaba
# �輸�鈭�暺恕嚗?
ALIBABA_API_KEY=your-api-key-here
ALIBABA_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
ALIBABA_MODEL=qwen-plus
ALIBABA_TIMEOUT=120000
# Ollama嚗�唳芋撘�
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5:7b
OLLAMA_TIMEOUT=120000
# ====================
# 隡�摮
# ====================
SESSION_STORAGE=sqlite
SQLITE_DB_PATH=./data/sessions.db
SESSION_MAX_MESSAGES=100
# ====================
# 閫血�閫�
# ====================
CHAT_PREFIX=/ai
PRIVATE_AUTO_REPLY=true
GROUP_AI_TRIGGER=both
# ====================
# �亙�
# ====================
LOG_LEVEL=info| 撟喳 | �寧 | �晶憸漲 | �刻�� |
|---|---|---|---|
| �� �輸�鈭�� | ��敹恬�蝔喳� | �? | 潃�潃�潃? |
| �� DeepSeek | �找遠瘥� | �? | 潃�潃�潃? |
| �� �箄停 AI | �賭漣憭扳芋�? | �? | 潃�潃� |
| �� ��� | �踵��砍撩 | �? | 潃�潃� |
| �� OpenAI | GPT-4 | �� | 潃�潃� |
| �� Google Gemini | �晶憸漲憭? | �? | 潃�潃� |
| � �砍 Ollama | 摰�晶 | �� | 潃�潃����曉嚗 |
AI Robot 摰鈭�蝘�霈桃鈭�隞園�縑���冽��∪�瘨撟喳����扇敶頂蝏葉雿輻����霈柴�?
IM嚗�園�悖嚗像�啣�霈桀�銋�撠����臬像�堆�QQ�凝靽∠�嚗�� AI Robot ������?
interface IMAdapter {
name: string;
platform: 'wechat' | 'qq' | 'mock';
start(): Promise<void>;
stop(): Promise<void>;
sendReply(event: ChatMessageEvent, reply: ChatReply): Promise<void>;
onMessage(handler: (event: ChatMessageEvent) => Promise<void>): void;
}interface ChatMessageEvent {
platform: Platform;
chatType: 'private' | 'group';
messageId: string;
senderId: string;
senderName?: string;
roomId?: string;
roomName?: string;
text: string;
mentions?: string[];
isAt?: boolean;
replyToMessageId?: string;
timestamp: number;
raw?: unknown;
}| ���? | �悅 | 隡��孵� | 蝡臬 |
|---|---|---|---|
| NapCatQQ | WebSocket | WS | 3001 |
| 敺桐縑 | HTTP | REST | �舫�蝵? |
LLM嚗之霂剛�璅∪�嚗�靘��悅摰�鈭�銝� AI ����� AI Robot ������?
interface LLMProvider {
name: string;
kind: 'local' | 'remote' | 'experimental';
generate(input: LLMGenerateRequest): Promise<LLMGenerateResponse>;
healthCheck(): Promise<boolean>;
listModels?(): Promise<string[]>;
}interface LLMGenerateRequest {
model?: string;
systemPrompt?: string;
messages: Array<{
role: 'system' | 'user' | 'assistant';
content: string;
}>;
temperature?: number;
topP?: number;
maxTokens?: number;
metadata?: Record<string, unknown>;
}interface LLMGenerateResponse {
provider: string;
model: string;
content: string;
usage?: {
promptTokens?: number;
completionTokens?: number;
totalTokens?: number;
};
raw?: unknown;
}NapCatQQ 雿輻 WebSocket 摰 QQ 摰X蝡臭� AI Robot 銋���嗅���縑�?
| � | �? |
|---|---|
| �悅 | WebSocket |
| 暺恕 URL | ws://localhost:3001 |
| 瘨�澆� | JSON |
| 蝻� | UTF-8 |
*隡瘨嚗�?NapCatQQ嚗?
{
"post_type": "message",
"message_type": "group",
"user_id": 123456789,
"group_id": 987654321,
"sender": {
"nickname": "�冽",
"card": "蝢文��?
},
"message": [
{ "type": "text", "text": "雿末" },
{ "type": "at", "data": { "qq": 987654321 } }
],
"raw_message": "雿末 @�箏鈭?,
"time": 1234567890
}*隡瘨嚗�� NapCatQQ嚗?
{
"message_type": "group",
"group_id": 987654321,
"message": "���捆"
}�輸�鈭?DashScope API ��撖寥��蝟餃�霂剛�璅∪��挪�柴�?
| �臬� | URL |
|---|---|
| �漣�臬� | https://dashscope.aliyuncs.com/compatible-mode/v1 |
| 撖寡�銵亙 | /chat/completions |
Authorization: Bearer sk-xxxxxxxxxxxxxxxx
Content-Type: application/json{
"model": "qwen-plus",
"messages": [
{ "role": "system", "content": "雿銝�銝芣�撣桀���? },
{ "role": "user", "content": "雿末嚗? }
],
"temperature": 0.7,
"max_tokens": 2048
}| 璅∪� | 銝��? | �膩 |
|---|---|---|
qwen-turbo |
8K | 敹恍���找遠瘥� |
qwen-plus |
32K | 撟唾﹛�扯 |
qwen-max |
32K | ��雿唾捶�? |
qwen-long |
1M | �蹂�銝� |
Ollama ���砍 REST API �其�餈�撘�皞祗閮�璅∪��?
| 蝡舐 | URL |
|---|---|
| �箇� URL | http://localhost:11434 |
| 撖寡� API | /api/chat |
| 璅∪��” | /api/tags |
{
"model": "qwen2.5:7b",
"messages": [
{ "role": "user", "content": "雿末嚗? }
],
"stream": false,
"options": {
"temperature": 0.7,
"top_p": 0.9,
"num_predict": 512
}
}隡�摮�悅摰�鈭笆霂��脩�����璉�蝝X撘�?
interface SessionStore {
getSession(sessionId: string): Promise<SessionMessage[]>;
appendMessage(sessionId: string, message: SessionMessage): Promise<void>;
clearSession(sessionId: string): Promise<void>;
}CREATE TABLE sessions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
session_id TEXT NOT NULL,
role TEXT NOT NULL,
content TEXT NOT NULL,
timestamp INTEGER NOT NULL,
created_at INTEGER DEFAULT (strftime('%s', 'now'))
);
CREATE INDEX idx_session_id ON sessions(session_id);
CREATE INDEX idx_timestamp ON sessions(session_id, timestamp);�?prompts/ �桀��遣�芸�銋�蝷箄�嚗?
prompts/
���� default/
�? ���� friendly.txt
�? ���� tech-expert.txt
���� group/
�? ���� active.txt
�? ���� concise.txt
���� helper/
���� assistant.txt
// �券�蝵桐葉
LLM_PROVIDER=ollama // ��唳�唳芋�?
OLLAMA_MODEL=llama3:8b# 隞�摨?@ ��
GROUP_AI_TRIGGER=at
# 隞�摨�蝻��賭誘
GROUP_AI_TRIGGER=prefix
# 銝方���嚗�霈歹�
GROUP_AI_TRIGGER=bothpnpm doctor璉��仿★�殷�
- Node.js �
- �蔭�辣
- API 餈
- NapCatQQ 餈
- SQLite �嗆�?
� �箏鈭箸瓷��摨?/summary>
- 蝖株恕 NapCatQQ 甇�餈�
- 璉��?WebSocket 餈嚗ws://localhost:3001`嚗?
- 蝖桐�
.env 銝?QQ_ENABLED=true
- 撉� API Key 撌脤�蝵?
- 璉��交�行迤蝖?@ �箏鈭?
.env 銝?QQ_ENABLED=true� API 餈憭梯揖
- 撉� API Key 甇�&
- 璉��亥揭�瑟��舐憸漲
- 瘚�蝵�餈嚗ping dashscope.aliyuncs.com`
- 撉� Base URL 甇�&
� SQLite �秤
- 璉��亦敶��?
- 撉�蝤�蝛粹
- �撟園�撱箸�桀�嚗?
rm data/sessions.db
| �秤 | �思� | 閫��寞� |
|---|---|---|
401 Unauthorized |
API Key �� | 璉��?API Key �蔭 |
Connection refused |
��芸�? | �臬撖孵�� |
WebSocket closed |
NapCatQQ �剖� | � NapCatQQ |
Model not found |
璅∪�銝��? | 銝蝸璅∪����亙�蝘? |
Out of credit |
雿�銝雲 | ��潸揭�? |
�賑甈Z����耦撘�韐∠嚗?
- Fork �砌�摨?
- �遣�寞�批��荔�
git checkout -b feature/AmazingFeature - 餈��湔
- 餈�瘚�嚗pnpm test`
- �漱嚗git commit -m 'Add AmazingFeature'`
- �券��
git push origin feature/AmazingFeature - �漱 Pull Request
# 摰�靘�
pnpm install
# 撘��芋撘�銵?
pnpm dev
# 餈�隞��璉��?
pnpm lint
# 蝐餃�璉��?
pnpm typecheck
# �遣
pnpm build霂西� CONTRIBUTING.md
�祇★�桅��典��悅璅∪�嚗?
| 蝏辣 | �悅 |
|---|---|
| 撘�皞�? | MIT License |
| ���典� | ��霈詨�悅 |
霂西� LICENSE
霂西� CHANGELOG.md
[2.0.0] - 2024-03-26
- �� �冽�?Electron 獢摨�嗆�
- � �箔� Vue 3 + TypeScript �隞���
- �� �劓銝駁� UI 霈曇恣
- � 蝞��芋撘�銝�璅∪��芋撘��?
- � �航���蝵桀�撖?
- �� �舀�憭像�?AI API
- � �舀��砍 Ollama 璅∪�
- �� �辣蝟餌��嗆�
- �� 銝���韐孵��?
- �� �銝駁��舀�
| 皜� | �暹 |
|---|---|
| � �桃拳 | contact@ai-robot.dev |
| � QQ蝢? | 123456789 |
| �� 摰� | https://ai-robot.dev |
| �� �﹝ | https://docs.ai-robot.dev |
| �� �桅��� | GitHub Issues |
Made with �歹� by AI Robot Team
*潃?憒�餈葵憿寧撖嫣��葬�抬�霂瑞�銝�銝?Star 潃?