Agent Information Field - Norm Repository
Project description
AIF (Agent Information Field)
基于组织符号学的 LLM Agent 协作治理基础设施。
项目状态
当前已包含可运行的 Normbase / EDA / MCP 适配层,并已提供发布形态:
- Python:
aif-normbase(通过uvx --from aif-normbase aif-mcp调用) - Node wrapper:
@langxai/aif-mcp(通过npx -y @langxai/aif-mcp调用)
项目结构
aif/
├── normbase/ # 规范库核心模块
│ ├── models/ # 数据模型 (Norm, NormVersion, Schemas)
│ ├── api/ # API 路由 (norms, retrieve)
│ ├── services/ # 业务逻辑 (retrieval)
│ ├── db/ # 数据库 (schema.sql, connection)
│ └── prompts/ # 提示词模板
├── eda_agent/ # EDA Agent 模块
│ ├── state.py # EDA 状态管理 (Belief, NormBinding, ValueWeight)
│ ├── engine.py # 推理引擎 (E/D/A 组件)
│ └── api/ # Agent API
├── llm/ # LLM 模块 (providers)
├── integrations/mcp/ # MCP 适配层 + npm wrapper
├── scripts/ # 构建/发布/运维脚本
├── tests/ # 测试 & 种子数据
│ └── tmp/ # 种子脚本 (EU AI Act, 交通法规等)
├── docker-compose.yml # 本地开发环境
├── pyproject.toml # Python 包配置 (aif-normbase)
├── requirements.txt # 依赖
└── README.md
模块说明
normbase
规范库核心,提供:
- ✅ 规范 CRUD 操作 (obligation/prohibition/permission)
- ✅ 检索:agent_role + field_ids 双通道 (RRF融合)
- ✅ 向量语义检索 (Qdrant)
- ✅ 版本管理 (norm_versions)
- ✅ 规范关系 (norm_relations)
- ⬜ Redis 缓存
- ⬜ 规范萃取流水线
- ✅ MCP 适配(通过
integrations/mcp暴露工具)
eda_agent
EDA Agent 运行时 (Phase 6 完成):
- ✅ E(认识论)信念管理 (Belief)
- ✅ D(义务论)规范绑定 (NormBinding)
- ✅ A(价值论)权重推理 (ValueWeight)
- ✅ 合规校验基础
- ⬜ 完整推理流程
技术栈
- FastAPI + PostgreSQL 16 + JSONB
- SQLAlchemy 2.0 (async)
- Qdrant (向量检索)
- Redis (缓存 - 集成中)
- LLM: OpenAI / Anthropic
快速开始
# 创建并激活 conda 虚拟环境(首次)
conda create -n aif python=3.11 -y
conda activate aif
# (可选)使用 venv 而不是 conda
# python -m venv .venv
# .venv\Scripts\activate
# 启动本地开发环境 (PostgreSQL + Qdrant + Redis)
docker-compose up -d
# 安装依赖
pip install -r requirements.txt
MCP(本地开发)
# 直接启动 MCP 适配器(stdio)
python -m integrations.mcp.server --transport stdio
MCP(分发调用)
# Python 入口(推荐)
uvx --from aif-normbase aif-mcp --transport stdio
# Node 包装入口
npx -y @langxai/aif-mcp
启动 API Server
# Normbase API 端口 8001
python -m normbase.main
API 文档:http://localhost:8001/docs
启动 EDA Agent Server
# EDA Agent API 端口 8002
python -m eda_agent.main
EDA API 文档:http://localhost:8002/docs
启动 Web 管理界面(Dashboard)
# Unified Dashboard(默认端口 8010)
python -m dashboard.main
如需使用轻量旧版 Normbase Admin(仅规范管理):
python -m normbase.admin
开发计划
阶段进度
| Phase | 内容 | 状态 |
|---|---|---|
| Phase 1 | 基础骨架 + CRUD + 管理UI | ✅ |
| Phase 2 | 检索核心 + 向量库 + 缓存 | ✅ |
| Phase 3 | 萃取流水线 + 审核UI | ⬜ |
| Phase 4 | MCP集成 + API鉴权 | ⬜ |
| Phase 5 | 打磨验证 + Demo | ⬜ |
| Phase 6 | EDA状态管理 + 持久化 | ✅ |
| Phase 7 | EDA推理引擎核心 | ⬜ |
| Phase 8 | 价值排序 + 合规校验 | ⬜ |
| Phase 9 | EDA端到端集成 | ⬜ |
API 端点
GET /- 健康检查GET /api/v1/norms- 规范列表POST /api/v1/norms- 创建规范GET /api/v1/norms/{id}- 规范详情PUT /api/v1/norms/{id}- 更新规范DELETE /api/v1/norms/{id}- 删除规范GET /api/v1/retrieve- 规范检索
测试数据
测试种子脚本位于 tests/tmp/:
seed_eu_ai_act.py- EU AI Act 规范seed_zh.py/seed_en.py- 中英文测试规范seed_traffic_laws.py- 交通法规
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aif_normbase-0.1.3.tar.gz
(53.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aif_normbase-0.1.3.tar.gz.
File metadata
- Download URL: aif_normbase-0.1.3.tar.gz
- Upload date:
- Size: 53.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49e59ce197924ab5d88fac2810a4414c76a097699194d77cbf3b034dd36b4a4b
|
|
| MD5 |
41bc2629b7a9a938eba8b23309aade21
|
|
| BLAKE2b-256 |
07729738fe9f61881ab576c85187fb5b1adf7fc3777bc41983ac1a0c09d80f15
|
File details
Details for the file aif_normbase-0.1.3-py3-none-any.whl.
File metadata
- Download URL: aif_normbase-0.1.3-py3-none-any.whl
- Upload date:
- Size: 61.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf007fb433348f6115d310c4eb2acc27b0e2f9581aa8cb564239e3606c0a907c
|
|
| MD5 |
e68e322a3f0d6291cf58c113e6bc986d
|
|
| BLAKE2b-256 |
548d07f47f6c749854cc65527dbd16b59ba7163fea91f6e06f5a82ce50ab34b3
|