generative-agent-assistant 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- generative_agent_assistant-0.1.0/.gitignore +77 -0
- generative_agent_assistant-0.1.0/LICENSE +21 -0
- generative_agent_assistant-0.1.0/PKG-INFO +324 -0
- generative_agent_assistant-0.1.0/README_SDK.md +295 -0
- generative_agent_assistant-0.1.0/db/init/001_schema_ddl.sql +173 -0
- generative_agent_assistant-0.1.0/pyproject.toml +158 -0
- generative_agent_assistant-0.1.0/src/gca/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/agent/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/agent/loop.py +846 -0
- generative_agent_assistant-0.1.0/src/gca/agent/mcp_client.py +412 -0
- generative_agent_assistant-0.1.0/src/gca/agent/tools.py +479 -0
- generative_agent_assistant-0.1.0/src/gca/api/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/api/deps.py +34 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/agent.py +65 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/auth.py +29 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/chat.py +44 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/folders.py +42 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/health.py +13 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/materials.py +28 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/endpoints/sessions.py +74 -0
- generative_agent_assistant-0.1.0/src/gca/api/v1/router.py +24 -0
- generative_agent_assistant-0.1.0/src/gca/cli.py +835 -0
- generative_agent_assistant-0.1.0/src/gca/config.py +232 -0
- generative_agent_assistant-0.1.0/src/gca/main.py +150 -0
- generative_agent_assistant-0.1.0/src/gca/middleware/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/models/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/observability/__init__.py +3 -0
- generative_agent_assistant-0.1.0/src/gca/observability/langfuse.py +255 -0
- generative_agent_assistant-0.1.0/src/gca/orm/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/orm/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/orm/database.py +632 -0
- generative_agent_assistant-0.1.0/src/gca/py.typed +0 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/__init__.py +13 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/auth.py +34 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/chat.py +35 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/folder.py +11 -0
- generative_agent_assistant-0.1.0/src/gca/schemas/session.py +21 -0
- generative_agent_assistant-0.1.0/src/gca/services/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/services/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/services/agent_service.py +428 -0
- generative_agent_assistant-0.1.0/src/gca/services/auth_service.py +48 -0
- generative_agent_assistant-0.1.0/src/gca/services/chat_service.py +381 -0
- generative_agent_assistant-0.1.0/src/gca/services/folder_service.py +39 -0
- generative_agent_assistant-0.1.0/src/gca/services/material_service.py +199 -0
- generative_agent_assistant-0.1.0/src/gca/services/session_service.py +213 -0
- generative_agent_assistant-0.1.0/src/gca/static/THIRD_PARTY_NOTICES.md +119 -0
- generative_agent_assistant-0.1.0/src/gca/static/bg.png +0 -0
- generative_agent_assistant-0.1.0/src/gca/static/echarts.min.js +45 -0
- generative_agent_assistant-0.1.0/src/gca/static/index.html +1835 -0
- generative_agent_assistant-0.1.0/src/gca/static/marked.min.js +6 -0
- generative_agent_assistant-0.1.0/src/gca/static/purify.min.js +3 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/__init__.py +0 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/agent_bash.sb +11 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/agent_tasks.py +102 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/broker.py +160 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/parse_tasks.py +128 -0
- generative_agent_assistant-0.1.0/src/gca/tasks/scheduler.py +24 -0
- generative_agent_assistant-0.1.0/src/gca/utils/README.md +6 -0
- generative_agent_assistant-0.1.0/src/gca/utils/__init__.py +1 -0
- generative_agent_assistant-0.1.0/src/gca/utils/doc_parser.py +108 -0
- generative_agent_assistant-0.1.0/src/gca/utils/llm_client.py +683 -0
- generative_agent_assistant-0.1.0/src/gca/utils/minio_client.py +141 -0
- generative_agent_assistant-0.1.0/src/gca/utils/nacos_client.py +278 -0
- generative_agent_assistant-0.1.0/src/gca/utils/security.py +74 -0
- generative_agent_assistant-0.1.0/src/gca/utils/snowflake.py +150 -0
- generative_agent_assistant-0.1.0/src/gca/utils/somark_client.py +125 -0
- generative_agent_assistant-0.1.0/src/gca/workers/README.md +6 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.pyo
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
|
|
8
|
+
# Node / 前端
|
|
9
|
+
node_modules/
|
|
10
|
+
dist/
|
|
11
|
+
|
|
12
|
+
# 环境变量与密钥
|
|
13
|
+
.env
|
|
14
|
+
.env.local
|
|
15
|
+
.env.pg-mcp
|
|
16
|
+
# 问数 MCP 迁入后的真实配置(含 PG DSN),只提交 .env.nl2sql.example
|
|
17
|
+
.env.nl2sql
|
|
18
|
+
# standalone 部署的容器视角配置(含真实密钥,只提交 .env.docker.example)
|
|
19
|
+
deploy/.env.docker
|
|
20
|
+
# 语义图谱 Neo4j 实例的密码,只提交 .env.neo4j-gca.example
|
|
21
|
+
.env.neo4j-gca
|
|
22
|
+
|
|
23
|
+
# Redis
|
|
24
|
+
dump.rdb
|
|
25
|
+
|
|
26
|
+
# macOS
|
|
27
|
+
.DS_Store
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
|
|
33
|
+
# Claude Code 本地配置
|
|
34
|
+
.claude/settings.local.json
|
|
35
|
+
|
|
36
|
+
# Claude Code project-level state (personal)
|
|
37
|
+
.claude/TASK.md
|
|
38
|
+
.claude/memory/
|
|
39
|
+
|
|
40
|
+
# SQLite 数据库文件(不入库,schema.sql 才入库)
|
|
41
|
+
app/db/*.db
|
|
42
|
+
app/db/*.db-*
|
|
43
|
+
|
|
44
|
+
# db/ 目录下的 SQLite 数据文件
|
|
45
|
+
db/*.db
|
|
46
|
+
db/*.db-*
|
|
47
|
+
|
|
48
|
+
# Obsidian 编辑器配置
|
|
49
|
+
.obsidian/
|
|
50
|
+
db/_backup_*/
|
|
51
|
+
|
|
52
|
+
# agent loop 沙箱:模型写盘产物不入库
|
|
53
|
+
agent_workspace/
|
|
54
|
+
|
|
55
|
+
# Nacos SDK 运行时快照缓存(配置内容含凭据值,绝不入库;P7 引入)
|
|
56
|
+
nacos-data/
|
|
57
|
+
|
|
58
|
+
# 并行 Codex 会话本地工具链,不入库(含本机绝对路径、指向不存在的 .Codex 死链、
|
|
59
|
+
# tests/test_cors.py 断言旧白名单 CORS 与现通配配置冲突):保留本机可用、挡在共享仓库外
|
|
60
|
+
/.codex/
|
|
61
|
+
/AGENTS.md
|
|
62
|
+
/tests/test_cors.py
|
|
63
|
+
|
|
64
|
+
# 开发态脚本日志与 pid(app_start.sh 产物)
|
|
65
|
+
logs/
|
|
66
|
+
|
|
67
|
+
# 问数 MCP 的 BGE 模型与运行数据(约 110MB,走本地目录/volume,不入库)
|
|
68
|
+
vanna_data/
|
|
69
|
+
|
|
70
|
+
# 问数 MCP 运行数据目录(run_sql 的 query_results_*.csv 落盘,dev 裸进程态产物)
|
|
71
|
+
nl2sql_data/
|
|
72
|
+
|
|
73
|
+
# P9.6 复测日志:含 user 名与(旧脚本的)口令长度,不入库;跑测证据在 on_r*.jsonl 与 verdicts_*
|
|
74
|
+
datasets/p9_runs/*.log
|
|
75
|
+
datasets/p10_runs/*.log
|
|
76
|
+
# P12.2 影子对账原始逐条日志(含全部 SQL 文本与取回值);读数结论在 shadow_r*.md
|
|
77
|
+
datasets/p12_runs/*.log
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Albert Xu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: generative-agent-assistant
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A general-purpose generative agent runtime: ReAct loop, sessions, SSE streaming, MCP tool registry, charts and approvals, served by FastAPI with a built-in web UI.
|
|
5
|
+
Author-email: Albert Xu <xualbert83@outlook.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: aiosqlite>=0.22.1
|
|
10
|
+
Requires-Dist: anyio>=4.14.1
|
|
11
|
+
Requires-Dist: fastapi>=0.115.0
|
|
12
|
+
Requires-Dist: httpx>=0.27.0
|
|
13
|
+
Requires-Dist: langfuse<3,>=2
|
|
14
|
+
Requires-Dist: mammoth>=1.12.0
|
|
15
|
+
Requires-Dist: markdownify>=1.2.3
|
|
16
|
+
Requires-Dist: mcp<2,>=1.28.1
|
|
17
|
+
Requires-Dist: minio>=7.2.20
|
|
18
|
+
Requires-Dist: nacos-sdk-python==3.2.0
|
|
19
|
+
Requires-Dist: pillow>=12.3.0
|
|
20
|
+
Requires-Dist: pwdlib[argon2]>=0.3.0
|
|
21
|
+
Requires-Dist: pyjwt>=2.13.0
|
|
22
|
+
Requires-Dist: pymupdf4llm>=1.28.0
|
|
23
|
+
Requires-Dist: python-multipart>=0.0.32
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: taskiq-redis>=1.2.3
|
|
26
|
+
Requires-Dist: taskiq>=0.12.4
|
|
27
|
+
Requires-Dist: uvicorn[standard]>=0.30.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# generative-agent-assistant
|
|
31
|
+
|
|
32
|
+
**通用 ReAct agent 运行时** —— 会话持久化 / SSE 流式输出 / 工具注册 / 图表渲染 / 人工审批 /
|
|
33
|
+
子代理派发,自带一套开箱可用的 Web 界面,由 FastAPI 承载。
|
|
34
|
+
`pip install` 之后跑一次配置向导填上你自己的模型与中间件地址,一条命令起完整服务。
|
|
35
|
+
|
|
36
|
+
> A general-purpose ReAct agent runtime (sessions, SSE streaming, tool registry, charts,
|
|
37
|
+
> human approval, sub-agents) with a built-in web UI, served by FastAPI.
|
|
38
|
+
|
|
39
|
+
- 许可:MIT(随包的第三方前端库另有各自许可,见 `gca/static/THIRD_PARTY_NOTICES.md`)
|
|
40
|
+
- Python:**>= 3.12**
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install generative-agent-assistant
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
装完即有 `gca` 命令(`init` / `doctor` / `serve`)与 `import gca` 库入口。
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 60 秒上手
|
|
55
|
+
|
|
56
|
+
### 1. `gca init` —— 配置向导(只有 3 项必填)
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
$ gca init
|
|
60
|
+
GCA 配置向导 · 配置将写入 /Users/you/.gca/.env(权限 600)
|
|
61
|
+
|
|
62
|
+
[1/3] 大模型(必填,3 项)
|
|
63
|
+
API Base URL OpenAI 兼容端点 : http://127.0.0.1:18111/v1
|
|
64
|
+
模型名称 如 qwen-plus / glm-4.6 : qwen-plus
|
|
65
|
+
API Key (输入不回显):
|
|
66
|
+
✓ 端点连通(50 ms)
|
|
67
|
+
|
|
68
|
+
[2/3] 中间件(可选,直接回车跳过)
|
|
69
|
+
Redis URL redis://[:密码@]host:port/db :
|
|
70
|
+
– 已跳过:「异步任务·run_bash」不可用
|
|
71
|
+
MinIO Endpoint host:port :
|
|
72
|
+
– 已跳过:「文件上传·文档解析」不可用
|
|
73
|
+
|
|
74
|
+
[3/3] 服务
|
|
75
|
+
监听端口 [8001]:
|
|
76
|
+
|
|
77
|
+
自动处理(不问你):
|
|
78
|
+
· JWT_SECRET 已生成 48 字节随机密钥(唯一的启动阻断项,不用你操心)
|
|
79
|
+
· AGENT_BASH_SANDBOX 自动判定 = on(当前平台 Darwin)
|
|
80
|
+
· AGENT_WORKSPACE /Users/you/.gca/workspace(已创建)
|
|
81
|
+
· DB_PATH db/chat.db(相对 /Users/you/.gca,SQLite 首启自建)
|
|
82
|
+
|
|
83
|
+
降级清单(现在跳过,随时重跑 gca init 补上):
|
|
84
|
+
· 已跳过 Redis → 「异步任务·run_bash」不可用
|
|
85
|
+
· 已跳过 MinIO → 「文件上传·文档解析」不可用
|
|
86
|
+
|
|
87
|
+
默认跳过:Langfuse 可观测 / SoMark OCR / 配置中心(要配请跑 gca init --advanced)
|
|
88
|
+
|
|
89
|
+
✓ 已写入 /Users/you/.gca/.env(权限 600)
|
|
90
|
+
⚠ 该文件含明文密钥,勿提交 git、勿贴聊天窗。
|
|
91
|
+
|
|
92
|
+
下一步:gca doctor 自检 → gca serve 启动
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> 上面是一次真机实跑的原样输出。其中大模型端点用的是本地 stub(`127.0.0.1:18111`),
|
|
96
|
+
> 所以你会看到本地地址 —— 换成你自己的服务商端点即可。
|
|
97
|
+
|
|
98
|
+
### 2. `gca doctor` —— 起服前自检
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
$ gca doctor
|
|
102
|
+
配置文件 /Users/you/.gca/.env ✓ (权限 600)
|
|
103
|
+
JWT_SECRET 已配置(64 字符) ✓
|
|
104
|
+
大模型 http://127.0.0.1:18111/v1 model=qwen-plus ✓ 11 ms
|
|
105
|
+
Redis 未配置(可选) – 跳过 → 「异步任务·run_bash」不可用
|
|
106
|
+
MinIO 未配置(可选) – 跳过 → 「文件上传·文档解析」不可用
|
|
107
|
+
配置中心 未配置(可选) – 跳过
|
|
108
|
+
SQLite /Users/you/.gca/db/chat.db ✓ 可写
|
|
109
|
+
|
|
110
|
+
结论:可启动(2 项功能降级)
|
|
111
|
+
· Redis 未配置 → 「异步任务·run_bash」不可用
|
|
112
|
+
· MinIO 未配置 → 「文件上传·文档解析」不可用
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
退出码语义:**必填项不通过 → 1**(不该起服);**只有可选项降级 → 0**(可以起)。
|
|
116
|
+
|
|
117
|
+
### 3. `gca serve` —— 一键启动(含界面)
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
$ gca serve --port 18101
|
|
121
|
+
GCA 0.1.0 · home=/Users/you/.gca · 降级:Redis 未配 → 「异步任务·run_bash」不可用、MinIO 未配 → 「文件上传·文档解析」不可用
|
|
122
|
+
GCA 启动中 … http://127.0.0.1:18101 (GCA_HOME=/Users/you/.gca)
|
|
123
|
+
停止:Ctrl-C
|
|
124
|
+
INFO: Started server process [55650]
|
|
125
|
+
INFO: Waiting for application startup.
|
|
126
|
+
INFO: Application startup complete.
|
|
127
|
+
INFO: Uvicorn running on http://127.0.0.1:18101 (Press CTRL+C to quit)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
中间件都配齐时,第一行横幅变成:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
GCA 0.1.0 · home=/…/home_full · 全部功能可用
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
启动后:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
curl http://127.0.0.1:18101/health # {"status":"ok"}
|
|
140
|
+
open http://127.0.0.1:18101/ # 完整 Web 界面(89 KB HTML,静态资源随包发)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 4. 首次使用:先注册一个账号
|
|
144
|
+
|
|
145
|
+
界面是带鉴权的,**首次打开需要注册**(本地 SQLite 存用户,无外部依赖)。
|
|
146
|
+
在界面上按提示注册即可;也可以直接调接口:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
curl -X POST http://127.0.0.1:18101/api/auth/register \
|
|
150
|
+
-H 'Content-Type: application/json' \
|
|
151
|
+
-d '{"username":"yourname","password":"your-password"}'
|
|
152
|
+
# → 返回 access_token(注册即登录);登录走 /api/auth/login
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 配置说明
|
|
158
|
+
|
|
159
|
+
配置文件落在 **`$GCA_HOME/.env`(默认 `~/.gca/.env`,权限 600)**,
|
|
160
|
+
`gca init` 负责生成,你也可以直接手改。
|
|
161
|
+
|
|
162
|
+
### 必填:只有大模型三件套
|
|
163
|
+
|
|
164
|
+
| 键 | 说明 |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `LLM_BASE_URL` | OpenAI 兼容端点,如 `https://…/v1` |
|
|
167
|
+
| `LLM_DEFAULT_MODEL` | 默认模型名,如 `qwen-plus` |
|
|
168
|
+
| `LLM_API_KEY` | 你的 API Key(明文落盘,权限 600) |
|
|
169
|
+
|
|
170
|
+
不填这三项就没法对话;其余全部可自动生成、用默认值,或跳过后降级运行。
|
|
171
|
+
|
|
172
|
+
### 自动生成:`JWT_SECRET`
|
|
173
|
+
|
|
174
|
+
它是**唯一会让服务起不来的必配项**(空值或占位值直接 fail-fast),
|
|
175
|
+
所以向导用 48 字节随机数直接生成,不问你。
|
|
176
|
+
重跑 `gca init` 会**沿用已有值**,已签发的 token 不会失效。
|
|
177
|
+
|
|
178
|
+
### 可选:跳过之后具体哪些功能不可用
|
|
179
|
+
|
|
180
|
+
| 中间件 | 键 | 跳过后**不可用**的功能 | 其余功能 |
|
|
181
|
+
|---|---|---|---|
|
|
182
|
+
| Redis | `REDIS_HOST` / `PORT` / `PASSWORD` / `DB` | 异步任务队列、`run_bash` 工具 | 照常可用 |
|
|
183
|
+
| MinIO | `MINIO_ENDPOINT` / `ACCESS_KEY` / `SECRET_KEY` / `BUCKET_*` | 文件上传、文档解析(PDF/Word 转 Markdown) | 照常可用 |
|
|
184
|
+
|
|
185
|
+
**对话、SSE 流式、会话历史、图表渲染、审批、子代理都不依赖这两个中间件** ——
|
|
186
|
+
只填大模型三件套就能起服并正常聊天(这一点有实测:三个外部服务全指死端口仍启动成功)。
|
|
187
|
+
SQLite 会在 `$GCA_HOME/db/chat.db` 自建,无需你准备数据库。
|
|
188
|
+
|
|
189
|
+
`gca init --advanced` 还会追问:第二个模型 provider、文档 OCR、可观测平台、外部配置中心 —— 都可留空。
|
|
190
|
+
|
|
191
|
+
### 配置解析优先级
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
真实环境变量(shell export / 容器 -e) ← 最高,CI 与容器友好
|
|
195
|
+
> $GCA_HOME/.env
|
|
196
|
+
> 外部配置中心(仅当你显式配了地址才会尝试,失败自动回退 .env)
|
|
197
|
+
> 代码内默认值
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 非交互 / CI / 容器
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
gca init --non-interactive \
|
|
204
|
+
--set LLM_BASE_URL=https://your-endpoint/v1 \
|
|
205
|
+
--set LLM_MODEL=qwen-plus \
|
|
206
|
+
--set LLM_API_KEY=sk-xxx \
|
|
207
|
+
--set REDIS_URL=redis://:password@127.0.0.1:6379/0 \
|
|
208
|
+
--set MINIO_ENDPOINT=127.0.0.1:9000
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`REDIS_URL` 会自动拆成代码消费的四个键;`MINIO_ENDPOINT` 带 scheme 也会归一成 `host:port`。
|
|
212
|
+
非交互模式下**只从环境变量捡默认面的键**,不会把你 shell 里其它同名变量烤进配置文件。
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## ⚠ `--home` 是「粘」的
|
|
217
|
+
|
|
218
|
+
一旦你用了自定义目录:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
gca init --home /srv/gca # 配置写到 /srv/gca/.env
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
那么**后续每条命令都必须带上同样的 `--home`**,否则会去默认的 `~/.gca` 找配置:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
gca doctor --home /srv/gca
|
|
228
|
+
gca serve --home /srv/gca
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
等价写法是导出环境变量 `export GCA_HOME=/srv/gca`,之后三条命令都不用再带 `--home`。
|
|
232
|
+
**不带且默认目录没配置时**,`gca serve` 会打印引导文案让你先跑 `gca init`(不会甩 traceback)。
|
|
233
|
+
|
|
234
|
+
`$GCA_HOME` 同时是数据锚点:SQLite 库、agent 工作区、`mcp.json` 都按它解析。
|
|
235
|
+
换 home = 换一套数据。
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 接入你自己的 MCP 工具
|
|
240
|
+
|
|
241
|
+
本包只内置 5 个通用工具:`read_file` / `write_file` / `list_dir` / `run_bash` / `dispatch_agent`。
|
|
242
|
+
**领域能力(数据库、检索、内部系统…)请通过 MCP 自行接入** —— 在
|
|
243
|
+
`$GCA_HOME/mcp.json` 放一份配置即可:
|
|
244
|
+
|
|
245
|
+
```json
|
|
246
|
+
{
|
|
247
|
+
"servers": [
|
|
248
|
+
{
|
|
249
|
+
"id": "my-tools",
|
|
250
|
+
"name": "My Tools",
|
|
251
|
+
"enabled": true,
|
|
252
|
+
"transport": "streamable-http",
|
|
253
|
+
"url": "http://127.0.0.1:9000/mcp",
|
|
254
|
+
"headers": {},
|
|
255
|
+
"toolPrefix": "auto",
|
|
256
|
+
"modes": ["agent"]
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
字段语义:
|
|
263
|
+
|
|
264
|
+
- `enabled` 必须是 JSON 布尔 `true`(字符串 `"false"` 是 truthy,这里严格判定,避免「以为下线了其实在线」)
|
|
265
|
+
- `modes` 要包含 `"agent"` 才会在对话轮次里被装载
|
|
266
|
+
- `toolPrefix`:`"auto"`(缺省)→ 工具名前缀为 `mcp__my_tools__`;给空串 `""` 则用裸名
|
|
267
|
+
- 环境变量 `GCA_MCP_URL_<ID大写下划线>` 可覆盖 `url`(容器内换内线地址用),不影响工具名与路由
|
|
268
|
+
|
|
269
|
+
**没有 `mcp.json` 是完全正常的初始态**:配置加载返回空列表、不抛异常,
|
|
270
|
+
agent 直接走内置工具集,服务照常可用。
|
|
271
|
+
(只有**写坏了 JSON** 才会报错 —— 那是真错误,静默吞掉比报错更糟。)
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 作为库使用
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
from gca.main import app # ASGI 应用,直接交给 uvicorn
|
|
279
|
+
from gca.agent.loop import run_loop, run_loop_stream, dispatch
|
|
280
|
+
from gca.agent.tools import DEFAULT_TOOLS
|
|
281
|
+
from gca.agent.mcp_client import load_mcp_config
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
uvicorn gca.main:app --host 0.0.0.0 --port 8001
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
`import gca` 期间**零网络、零拨号**:不读包外路径、不连配置中心,配置与连接全部下沉到显式入口。
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 边界与已知限制
|
|
293
|
+
|
|
294
|
+
- **本包不含任何自然语言取数 / Text-to-SQL 能力**,也不含任何业务数据字典或行业口径。
|
|
295
|
+
它是一个纯粹的通用 agent 基座;这类能力请以 MCP 工具的形式自行接入。
|
|
296
|
+
- **`gca init` 的模型校验只发 `GET {base_url}/models` 探活,不发 chat 请求** ——
|
|
297
|
+
不替你烧配额。代价是:只开放 chat 接口、不实现 `/models` 的端点会被标成「可达但 HTTP 404」,
|
|
298
|
+
这属正常,可以直接继续。
|
|
299
|
+
- **Python `>= 3.12`**,3.11 及以下装不了。
|
|
300
|
+
- **API Key 明文落盘**在 `$GCA_HOME/.env`。文件权限已钉死 600、目录 700,
|
|
301
|
+
但仍请**勿提交 git、勿贴进聊天窗**。
|
|
302
|
+
- Redis / MinIO 需要你自备(向导只问 URL,不代管安装)。
|
|
303
|
+
- 默认监听 `127.0.0.1`(仅本机)。要对外提供服务请显式 `--host 0.0.0.0`,
|
|
304
|
+
并自行处理反向代理与 TLS。
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 第三方组件
|
|
309
|
+
|
|
310
|
+
随包的 `gca/static/` 内含三个 vendored 前端库,版权归各自作者,按各自许可分发:
|
|
311
|
+
|
|
312
|
+
| 库 | 版本 | 许可 |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| Apache ECharts | 5.6.1 | Apache-2.0 |
|
|
315
|
+
| marked | 12.0.2 | MIT |
|
|
316
|
+
| DOMPurify | 3.4.11 | Apache-2.0 OR MPL-2.0 |
|
|
317
|
+
|
|
318
|
+
完整版权行与许可声明见包内 **`gca/static/THIRD_PARTY_NOTICES.md`**。
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 许可
|
|
323
|
+
|
|
324
|
+
MIT © Albert Xu
|