Files
hunjing/shenshi/README.md
T

38 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 神识 · 魂镜模型网关(hunjing-shenshi / Shenshi)
> 文化命名「神识」(契约词典 §2.1):统一模型能力——Provider/Endpoint 接入、能力槽位、协议转换、路由、流式、BYOK、配额与成本。神识不拥有人物状态。
## 当前状态(rewrite/1.0 M0 骨架)
- 数据面 `POST /v1/chat/completions`:接受灵台内部 IR(`internal/ir`),经路由选适配器,以 SSE 流出标准化增量(`data: <Delta JSON>` + `data: [DONE]`);
- 当前唯一适配器为 `stub` 回声桩(`internal/transform/stub.go`),供端到端骨架验证;云 Provider(openai_compatible/anthropic)与本地元炁端点按 [重写执行计划](../docs/operations/rewrite-plan.md) M4 落地;
- 健康面 `GET /healthz` `GET /readyz`;
- 服务令牌:`SHENSHI_SERVICE_TOKEN` 配置时校验 `Authorization: Bearer`(开发档可空)。
## 目录结构
```text
shenshi/
main.go # 入口:配置与路由装配
internal/ir/types.go # IR 请求/增量(与灵台 app/shenshi_client/types.py 对齐)
internal/transform/ # 出站适配器(Adaptor 接口 + stub)
internal/route/registry.go # 槽位 → 端点候选注册表
internal/relay/sse.go # SSE 帧写出(X-Accel-Buffering: no)
internal/server/ # HTTP 服务与测试
```
## 本地运行
```bash
SHENSHI_PORT=8080 go run .
# 灵台侧配置(backend .env):SHENSHI_BASE_URL=http://127.0.0.1:8080
```
## 测试
```bash
go vet ./... && go test ./...
```
设计依据:[神识模型网关](../docs/architecture/shenshi-gateway.md);错误码段 HJ-2xxx 见[契约词典](../docs/contracts/contract-glossary.md) §15。