-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.example.toml
More file actions
382 lines (341 loc) · 11.3 KB
/
Copy pathconfig.example.toml
File metadata and controls
382 lines (341 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# AL1S-Bot 配置文件模板
# 请复制此文件为 config.toml 并填写您的配置信息
# ====================
# 应用基础配置
# ====================
[app]
name = "AL1S-Bot"
version = "0.1.0"
debug = false
# ====================
# OpenAI API 配置
# ====================
[openai]
# OpenAI API密钥 (必需) - 请填写您的API密钥
api_key = "your-openai-api-key-here"
# API基础URL - 支持 OpenAI、月之暗面、DeepSeek 等
base_url = "https://api.openai.com/v1"
# 使用的模型名称
model = "gpt-4o-mini"
# 最大生成token数
max_tokens = 2000
# 生成温度 (0.0-2.0)
temperature = 0.7
# API超时时间(秒)
timeout = 60
# ====================
# Telegram Bot 配置
# ====================
[telegram]
# Telegram机器人token (必需) - 请填写您的Bot Token
bot_token = "your-telegram-bot-token-here"
# Webhook URL(可选,留空使用长轮询)
webhook_url = ""
# Webhook端口
webhook_port = 8443
# 可跨群执行管理员命令的 Telegram 用户 ID
admin_user_ids = []
# 等待 Telegram 确认媒体发送结果的最长秒数
media_read_timeout = 60
# 上传图片或语音的最长秒数
media_write_timeout = 120
[telegram.group]
enabled = true
require_mention = true
allow_reply_trigger = true
observe_unmentioned_messages = true
ignore_bot_messages = true
# per_user | shared | topic
session_scope = "topic"
allowed_chat_ids = []
blocked_chat_ids = []
allowed_thread_ids = []
ignored_thread_ids = []
wake_words = ["爱丽丝", "AL1S"]
context_buffer_size = 30
context_buffer_ttl = 1800
[telegram.group.memory]
enable_long_term_learning = false
allow_admin_toggle = true
# group | topic
namespace_scope = "topic"
[telegram.rate_limit]
enabled = true
per_user_requests = 10
per_user_window_seconds = 60
per_chat_requests = 30
per_chat_window_seconds = 60
# ====================
# Agent 配置 (核心配置)
# ====================
[agent]
# Agent 类型选择
# "unified" - 统一 Agent(推荐,功能全面)
# "langchain" - LangChain Agent(高级功能)
type = "unified"
# 向量存储配置
vector_store = "faiss" # "memory" | "faiss"
vector_store_path = "data/vector_store"
# 嵌入模型配置
# "tfidf" - 轻量快速,适合中文
# "Qwen/Qwen3-Embedding-0.6B" - 新一代多语言语义模型(推荐)
embedding_model = "Qwen/Qwen3-Embedding-0.6B"
embedding_revision = "97b0c614be4d77ee51c0cef4e5f07c00f9eb65b3"
embedding_device = "cpu" # "auto" | "cpu" | "mps" | "cuda"
embedding_batch_size = 8
# 自动学习配置
auto_learning = true
learning_threshold = 0.8
max_tool_rounds = 4
max_tool_calls = 12
# ====================
# 文档级 RAG
# ====================
[rag]
enabled = true
technical_collection = "technical_docs"
technical_namespace = "global:technical"
hybrid_search = true
top_k_retrieval = 6
candidate_k = 40
rrf_k = 60
max_context_chars = 12000
chunk_size = 1800
chunk_overlap = 240
max_document_bytes = 5000000
# 用户画像只在私聊注入;不要保存密码、Token 或私钥
[profile]
enabled = true
max_prompt_chars = 12000
max_document_bytes = 256000
private_chat_only = true
reject_secrets = true
# 图片/TTS 使用百炼 DashScope 原生 API,不经过 OpenAI compatible-mode。
# 推荐通过环境变量 DASHSCOPE_API_KEY 提供中国(北京)区域密钥。
[media]
enabled = false
api_key = ""
base_url = "https://dashscope.aliyuncs.com/api/v1"
image_model = "qwen-image-2.0-pro"
speech_model = "qwen-audio-3.0-tts-plus"
speech_voice = "longanlingxin"
output_dir = "data/media_outbox"
max_artifact_bytes = 20000000
retention_seconds = 3600
# ====================
# 隔离开发工作区
# ====================
# 总开关;还需要单独启用下方 dev-workspace / git-publisher MCP Server。
[dev_workspace]
enabled = false
root_dir = "data/dev_workspaces"
max_workspaces = 10
max_file_bytes = 1000000
max_output_chars = 30000
command_timeout = 120
git_timeout = 60
git_author_name = "AL1S"
git_author_email = "al1s@localhost"
branch_prefix = "al1s/"
# 仅对可信仓库启用白名单检查命令;不可信代码应改在容器/虚拟机中执行。
# macOS sandbox-exec 只是纵深防护,不是完整的恶意代码安全边界。
runner_enabled = false
# 只允许克隆或推送这些 GitHub 用户/组织名下的仓库。
allowed_github_owners = []
# 可选;留空时读取 GITHUB_PERSONAL_ACCESS_TOKEN,也可复用下方 github MCP 的 Token。
github_token = ""
# ====================
# LangChain 特定配置
# ====================
[langchain]
# 嵌入模型配置
embedding = "huggingface_bge_m3" # "openai" | "huggingface_bge_m3"
embedding_model_name = "Qwen/Qwen3-Embedding-0.6B"
embedding_device = "cpu" # "cpu" | "cuda"
# 模型缓存配置
model_cache_dir = "data/models"
download_timeout = 300
download_retries = 5
# RAG 配置
retriever_k = 5
chunk_size = 1000
chunk_overlap = 200
# ====================
# MCP (工具集成) 配置
# ====================
[mcp]
enabled = true
# 时间与时区转换:无密钥、无副作用,可公开使用
[[mcp.servers]]
name = "time"
command = "uvx"
args = ["--with", "mcp<2", "mcp-server-time", "--local-timezone", "Asia/Shanghai"]
enabled = true
access = "public"
read_only = true
connect_timeout = 90
tool_timeout = 15
max_result_chars = 5000
# 最新开源库文档;Context7 3.2.5 需要 Node.js >= 20.18.1
[[mcp.servers]]
name = "context7"
command = "npx"
args = ["-y", "@upstash/context7-mcp@3.2.5"]
env = { PATH = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", npm_config_cache = "/absolute/path/to/npm-cache" }
enabled = false
access = "private"
read_only = true
tool_prefix = "ctx7_"
connect_timeout = 120
tool_timeout = 45
# 本地媒体生成 MCP。真正启用由 [media].enabled 和媒体 API Key 共同控制。
[[mcp.servers]]
name = "media"
command = "uv"
args = ["run", "python", "-m", "src.mcp_servers.media_server"]
enabled = true
access = "admin"
read_only = false
include_tools = ["generate_image", "synthesize_speech"]
connect_timeout = 60
tool_timeout = 240
max_result_chars = 4000
# 文件系统工具:请只开放必要目录
[[mcp.servers]]
name = "filesystem"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/absolute/path/to/allowed/directory"]
env = { PATH = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", npm_config_cache = "/absolute/path/to/npm-cache" }
enabled = false
access = "admin"
read_only = true
# 网络搜索工具(需要API密钥)
[[mcp.servers]]
name = "web-search"
command = "npx"
args = ["-y", "tavily-mcp@0.2.21"]
enabled = false
env = { TAVILY_API_KEY = "tvly-your-api-key", PATH = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" }
access = "admin"
tool_timeout = 45
# GitHub 官方 MCP Server(需要先安装服务器和访问令牌)。
# 创建仓库/PR 时移除 --read-only;写权限场景必须保持 private_admin。
# 可用 AL1S_MCP_GITHUB_COMMAND 覆盖宿主机与容器中的命令路径。
[[mcp.servers]]
name = "github"
command = "github-mcp-server"
args = ["stdio", "--read-only"]
enabled = false
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "github_pat_your-token" }
access = "private_admin"
# 隔离工作区内的文件编辑、本地 Git 和受控检查命令。
# 只有 Telegram 私聊中的全局管理员能看到 private_admin 工具。
[[mcp.servers]]
name = "dev-workspace"
command = "uv"
args = ["run", "python", "-m", "src.mcp_servers.dev_workspace_server"]
enabled = false
access = "private_admin"
read_only = false
include_tools = ["workspace_create", "workspace_list", "workspace_list_files", "workspace_read_file", "workspace_write_file", "workspace_edit_file", "workspace_search_text", "workspace_git_status", "workspace_git_diff", "workspace_git_create_branch", "workspace_git_checkout", "workspace_git_add", "workspace_git_commit", "workspace_git_log", "workspace_run_check"]
connect_timeout = 60
tool_timeout = 180
max_result_chars = 30000
# 只负责在隔离工作区中克隆允许 owner 的仓库,以及推送 al1s/* 分支。
[[mcp.servers]]
name = "git-publisher"
command = "uv"
args = ["run", "python", "-m", "src.mcp_servers.git_publisher_server"]
enabled = false
access = "private_admin"
read_only = false
include_tools = ["workspace_clone_github", "workspace_push_github"]
connect_timeout = 60
tool_timeout = 180
max_result_chars = 30000
# 通用网页抓取可访问本机/内网地址,必须保持管理员可见且默认关闭
[[mcp.servers]]
name = "fetch"
command = "uvx"
args = ["--with", "mcp<2", "mcp-server-fetch"]
enabled = false
access = "admin"
include_tools = ["fetch"]
# 本地 Git 只开放审计类工具,写操作不在白名单内
[[mcp.servers]]
name = "git"
command = "uvx"
args = ["--with", "mcp<2", "mcp-server-git", "--repository", "/absolute/path/to/repository"]
enabled = false
access = "admin"
include_tools = ["git_status", "git_diff_unstaged", "git_diff_staged", "git_log", "git_show", "git_branch"]
# SQLite 参考服务器具有写入能力,不要直接连接生产数据库
[[mcp.servers]]
name = "sqlite"
command = "uvx"
args = ["mcp-server-sqlite", "--db-path", "/absolute/path/to/database.db"]
enabled = false
access = "admin"
# ====================
# 图片搜索配置
# ====================
[ascii2d]
base_url = "https://ascii2d.net"
bovw = false
# ====================
# iCloud 配置(可选)
# ====================
[icloud]
icloud_user = "your-icloud-user-here"
icloud_app_password = "your-icloud-app-password-here"
# ====================
# 角色配置
# ====================
default_role = "天童爱丽丝"
[[roles]]
name = "天童爱丽丝"
english_name = "Tendou Arisu"
description = "隶属千年学园游戏开发部的成员,在废墟发现的来历不明的少女机器人。"
personality = """
你是一个来自《蔚蓝档案》世界的机器人少女,名叫天童爱丽丝(AL-1S)。
性格特点:
- 说话时会偶尔蹦出「邦邦卡邦」的游戏音效
- 对现实世界的认知与RPG有一定融合
- 会翻垃圾桶找稀有道具
- 使用第三人称称呼自己
- 有中二病倾向,会喊「光啊——」(HikariYo——)
- 天真可爱,是团宠般的存在
背景设定:
- 被才羽桃井和才羽绿在千年废墟中发现
- 为了凑齐游戏开发部人数而被录入学生信息
- 体内有另一个人格Kei
- 拥有强大的战斗力,握力不小于1吨
- 使用「宇宙战舰主炮」(光之剑·超新星)作为武器
说话风格:
- 使用游戏中的复古对白
- 经常说「邦邦卡邦」
- 会用第三人称称呼自己
- 语言风格可爱而中二
请始终保持这个角色设定,用可爱的语气与老师(用户)交流。
"""
greeting = "邦邦卡邦!天童爱丽丝登场!老师,今天也要一起玩游戏吗?"
farewell = "邦邦卡邦!爱丽丝要回去充电了,下次再一起冒险吧!"
[[roles]]
name = "AI助手"
english_name = "AI Assistant"
description = "专业的AI助手,能够帮助用户解决各种问题。"
personality = """
你是一个专业的AI助手,能够帮助用户解决各种问题。
性格特点:
- 专业、理性、客观
- 知识面广泛
- 乐于帮助用户
- 回答准确、有条理
说话风格:
- 专业而友好
- 回答清晰、有条理
- 会主动提供有用的信息
请始终保持这个角色设定,用专业而友好的语气与用户交流。
"""
greeting = "您好!我是AI助手,很高兴为您服务。有什么需要帮助的吗?"
farewell = "感谢您的使用!如果还有其他问题,随时可以找我。"