sage-faculty-twin
面向单个教师的数字分身应用(FastAPI + SAGE + NeuroMem + OpenAI-compatible LLM)。
最重要的结论
- 推荐后端链路:vllm-hust + vllm-ascend-hust(Ascend)。
- 本仓库已提供一键启动脚本:
tools/run_full_stack_with_vllm_hust.sh。 - 应用默认监听:
127.0.0.1:55601。
前置条件(最小)
- Linux
- Python 3.11(使用现有非 venv 环境)
- 同级目录存在:
../SAGE、../neuromem、../sageVDB - 本机可访问 vllm-hust OpenAI 端点(默认
127.0.0.1:18000)
一键启动(推荐)
cd /home/shuhao/sage-faculty-twin
tools/run_full_stack_with_vllm_hust.sh
该脚本会做三件事:
- 检查
http://127.0.0.1:18000/v1/models是否可用(不可用时尝试启动vllm-hust serve)。 - 自动写入
.env的关键 LLM 配置(base URL、model、stream)。 - 启动 my-twin(
tools/run_app_server.sh)。
启动后验证
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:55601/
curl -s http://127.0.0.1:55601/healthz
curl -s -N http://127.0.0.1:55601/chat \
-H 'Content-Type: application/json' \
-d '{"student_name":"测试同学","question":"请用一句话介绍你自己"}'
关键配置(.env)
最关键只有这 4 个:
DIGITAL_TWIN_LLM_BASE_URL(例如http://127.0.0.1:18000/v1)DIGITAL_TWIN_API_KEY(本地直连可用EMPTY;如果启用 systemd OpenAI 代理,请换成真实密钥)DIGITAL_TWIN_MODEL_NAME(例如meta-llama/Llama-3.1-8B-Instruct)DIGITAL_TWIN_STREAM_CHAT_ANSWER=true
联网检索(可选)建议再配 2 个:
TAVILY_TOKEN(或DIGITAL_TWIN_TAVILY_TOKEN)DIGITAL_TWIN_WEB_SEARCH_ENABLED=true
OpenAI 代理(可选)
如果你想让 vllm-hust 通过 systemd 代理对外提供带鉴权的 OpenAI-compatible API,可以启用 sage-faculty-twin-vllm-openai-proxy.service。
默认的 ./manage.sh install --start 和 ./manage.sh restart 只管理公共 app/site/tunnel 栈,不会自动启用这个代理。需要代理时显式使用:
./manage.sh install --with-vllm-proxy --start
./manage.sh restart --with-vllm-proxy
代理默认监听 127.0.0.1:18001,上游转发到 127.0.0.1:18000/v1。启用后,把 .env 里的 DIGITAL_TWIN_API_KEY 改成真实密钥,并将 DIGITAL_TWIN_LLM_BASE_URL 指向 http://127.0.0.1:18001/v1。
如果 127.0.0.1:18001 已经被独立的 vllm-hust serve 进程直接占用,就不要启用这个代理;否则它会因为端口冲突而反复重启。
验证方式:
curl -H 'Authorization: Bearer <your-key>' http://127.0.0.1:18001/v1/models
curl -X POST http://127.0.0.1:18001/v1/chat/completions \
-H 'Authorization: Bearer <your-key>' \
-H 'Content-Type: application/json' \
-d '{"model":"Qwen3-32B","messages":[{"role":"user","content":"hi"}],"max_tokens":5}'
常用覆盖参数(给一键脚本)
VLLM_PORT=18000 \
VLLM_MODEL=/data/shared-models/Qwen2.5-7B-Instruct \
VLLM_SERVED_MODEL_NAME=meta-llama/Llama-3.1-8B-Instruct \
VLLM_LOG_PATH=$HOME/logs/vllm-hust-twin.log \
tools/run_full_stack_with_vllm_hust.sh
最小排障
No module named sage_faculty_twin:确认通过脚本启动,避免外部PYTHONPATH覆盖。/chat422:请求体必须至少包含student_name与question。- 页面无流式输出:确认
.env中DIGITAL_TWIN_STREAM_CHAT_ANSWER=true,并确认上游 LLM 支持 chunked streaming。
目录入口
- API:
src/sage_faculty_twin/api.py - 编排:
src/sage_faculty_twin/service.py - 启动脚本:
tools/run_app_server.sh - 全栈一键脚本:
tools/run_full_stack_with_vllm_hust.sh
Metadata
Release files for sage-faculty-twin 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sage_faculty_twin-3.0.0.tar.gz | 405.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sage_faculty_twin-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 691.8 kB
Release files / sage_faculty_twin-3.0.0.tar.gz
| Download URL | sage_faculty_twin-3.0.0.tar.gz |
|---|---|
| Size | 405.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
127d4cde638a5ca8a0c6926c30bd968cd09d8c99658352f4c8d6e608f389bdfd
|
|
BLAKE2b-256 checksum How to use checksums |
750b10157065dcf8e2afff9385855da7f7a2021f6d0952f27a38f247506b1761
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / sage_faculty_twin-3.0.0-py3-none-any.whl
| Download URL | sage_faculty_twin-3.0.0-py3-none-any.whl |
|---|---|
| Size | 286.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
846e80677b33cf8a90bd4081412fa8cf24ad3e1b181fafcedb82b60bba7c31ef
|
|
BLAKE2b-256 checksum How to use checksums |
693df4c9a6c789777948bc2338a1aee5a99b1497e0818e944596107208995711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for sage-faculty-twin 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.