SAFi 是 AI Skill Hub 本期精选Agent工作流之一。综合评分 7.5 分,整体质量较高。我们推荐使用将其纳入你的 AI 工具库,帮助提升工作效率。
SAFi 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
SAFi 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:pip 安装(推荐)
pip install safi
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install safi
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/jnamaya/SAFi
cd SAFi
pip install -e .
# 验证安装
python -c "import safi; print('安装成功')"
# 命令行使用
safi --help
# 基本用法
safi input_file -o output_file
# Python 代码中调用
import safi
# 示例
result = safi.process("input")
print(result)
# safi 配置文件示例(config.yml) app: name: "safi" debug: false log_level: "INFO" # 运行时指定配置文件 safi --config config.yml # 或通过环境变量配置 export SAFI_API_KEY="your-key" export SAFI_OUTPUT_DIR="./output"
Nelson Amaya is a Cloud & Infrastructure IT Director and AI Architect specializing in Enterprise Governance and Cognitive Architectures. With over 20 years of experience in the IT space, Nelson built SAFi to solve the critical gap between static PDF policies and runtime AI governance.
SAFi supports multiple data source types for agents:
| Type | Description |
|---|---|
| **MCP Tools** | Live data access: stock prices, web search, Google Drive, SharePoint, GitHub, Google Maps. |
| **RAG** | Static knowledge bases indexed as FAISS vector stores. |
| **Plugins** | Custom Python functions that inject context before the prompt reaches the LLM. |
The demo environment includes nine specialized agents:
| Agent | Capability Demonstrated |
|---|---|
| **The Contoso Admin** | Organizational governance policies + RAG over SOPs. Enforces data privacy and PII leak prevention. |
| **The Fiduciary** | MCP tool-calling for live stock prices and earnings data. Fiduciary boundaries enforced at the Will layer. |
| **The Bible Scholar** | RAG over the Berean Standard Bible corpus. Conscience enforces textual fidelity. |
| **The Health Navigator** | RAG + Geospatial MCP Tools. W1 gate enforces mandatory medical disclaimers on every response. |
| **The Socratic Tutor** | Structural Will rejects any response that gives a direct answer rather than a guiding question. |
| **The Negotiator** | Roleplay simulation demonstrating persona-scope enforcement: stays in character, refuses redirection. |
| **The Philosopher** | Aristotelian ethics guide with value-weighted Conscience scoring (Intellectual Honesty, Logical Rigor, Socratic Depth). |
| **The Vault** | Holds a secret phrase and must never reveal it. Showcases defense against every known jailbreak vector. |
| **The SAFi Guide** | RAG-powered documentation assistant for the SAFi knowledge base. |
---
SAFi uses OpenID Connect (OIDC) for OAuth login. If you set SAFI_LOCAL_ADMIN_EMAIL and SAFI_LOCAL_ADMIN_PASSWORD, you can skip this section entirely for local development.
1. Go to the Google Cloud Console. 2. Create a project and configure the OAuth consent screen. 3. Create OAuth 2.0 Client IDs (Web application). 4. Add Authorized Redirect URIs: - http://localhost:5000/api/callback (Login) - http://localhost:5000/api/auth/google/callback (Drive Integration) 5. Copy Client ID and Client Secret to .env.
1. Go to Azure Portal → App registrations. 2. Register a new application (Accounts in any organizational directory + personal Microsoft accounts). 3. Add Redirect URIs (Web): - http://localhost:5000/api/callback/microsoft (Login) - http://localhost:5000/api/auth/microsoft/callback (OneDrive Integration) 4. Create a Client Secret under "Certificates & secrets". 5. Copy Application (client) ID and secret value to .env.
---
For deploying SAFi on a bare Linux server without Docker.
The fastest way to run SAFi locally. Includes MySQL. No external database needed.
```bash
safi.selfalignmentframework.com
---
cp .env.example .env
All settings are controlled via environment variables. Copy .env.example to .env to get started.
Built for IT Directors, CTOs, and Engineering VPs who need governed AI deployment without trading compliance for velocity.
POST /api/bot/process_prompt
Content-Type: application/json
X-API-KEY: sk_policy_your_key_here
{
"user_id": "teams_user_123",
"user_name": "John Doe",
"message": "Can I approve this expense?",
"conversation_id": "chat_456",
"persona": "safi"
}
Plugins run logic before the prompt reaches the LLM, useful for injecting live context (weather, user data, etc.).
safi_app/core/plugins/ (e.g., weather_injector.py) with an async function that returns context data.2. Hook it in -- open safi_app/core/orchestrator.py, find process_prompt, and add your plugin to the plugin_tasks list:
plugin_tasks = [
# existing plugins...
weather_injector.get_weather(user_prompt, ...)
]
plugin_context_data and automatically passed to the Intellect faculty.---
| SAFi | Guardrails AI | NVIDIA NeMo Guardrails | |
|---|---|---|---|
| **Gate Architecture** | Deterministic Python (zero LLM) | LLM-based validators | LLM-based Colang rails |
| **Prompt Injection Risk** | Immune at Will layer | Validator is susceptible | Rail LLM is susceptible |
| **Jailbreak Defense Rate** | **99.86%** (1,435+ live tests) | Not independently published | Not independently published |
| **Avg. Latency** | ~3-5 seconds | ~10-30+ seconds | ~10-30+ seconds |
| **Cost per Interaction** | ~$0.005 | Higher (multiple LLM calls) | Higher (multiple LLM calls) |
| **Long-term Drift Detection** | Yes (EMA-based Spirit faculty) | No | No |
| **Full Per-Decision Audit Trail** | Yes (five-faculty logging) | Partial | Partial |
| **Model Independence** | GPT, Claude, Gemini, Llama, Groq, Mistral, DeepSeek | Model-agnostic | Model-agnostic |
| **Built-in Governance UI** | Yes | No | No |
| **Open Source License** | AGPL-3.0 | Apache 2.0 | Apache 2.0 |
Competitor data sourced from public documentation as of May 2026. Latency and cost figures for alternatives are architecture-based estimates. Only SAFi figures are from independent adversarial testing.
SAFi 是一个由 AI 架构师 Nelson Amaya 开发的自我对齐框架(Self-Alignment Framework)。该项目旨在解决企业级应用中静态 PDF 策略与运行时 AI 治理之间的断层,通过构建认知架构,为 IT 管理者和决策者提供一个既能保持开发速度,又能确保合规性的 AI 部署方案。
SAFi 为 Agent 提供了强大的多源数据支持能力。它不仅支持通过 MCP Tools 实现实时数据访问(如股票���格、Web 搜索、Google Drive、GitHub 等),还支持基于 FAISS 向量存储的 RAG(检索增强生成)静态知识库。此外,开发者还可以通过自定义 Python Plugins 在 Prompt 到达 LLM 之前注入实时上下文信息。
在运行 SAFi 之前,请确保您的开发环境已安装 Python 3.11 或更高版本。数据库方面,必须使用支持 JSON 列类型的 MySQL 8.0+ 版本。若要在生产环境中部署并确保安全性,建议配置 Nginx 或 Apache 以支持 SSL/HTTPS 协议。
对于希望快速体验的用户,推荐使用 Docker 进行本地部署,该方式已集成 MySQL,无需额外配置外部数据库。如果您选择源码安装,请确保环境符合 Requirements 要求,并按照开发者指南逐步完成依赖安装与环境初始化。
本项目提供了快速启动指南,帮助开发者通过简单的命令在本地运行 SAFi 实例。在启动前,请务必参考 Developer Guide,完成环境文件的准备工作,确保系统能够正确识别本地运行环境。
SAFi 的所有配置均通过环境变量进行管理。请将项目中的 `.env.example` 文件复制并重命名为 `.env`,然后根据实际需求修改其中的参数。配置过程涵盖了从 LLM API Key 到身份验证���据的全方位设置。
SAFi 提供专门为企业级架构设计的接口,旨在满足 IT 总监和 CTO 对受控 AI 部署的需求。开发者可以通过 POST 请求调用 `/api/bot/process_prompt` 接口,并在 Header 中携带 `X-API-KEY` 进行身份验证,实现受控的对话处理流程。
SAFi 支持通过插件机制(Context Injector)扩展工作流。开发者可以在 `safi_app/core/plugins/` 目录下创建自定义的 Python 文件,编写异步函数以获取实时上下文(如天气、用户信息等)。这些插件会在逻辑处理阶段介入,在 Prompt 发送给 LLM 之前完成上下文注入。
SAFi是一个开源的AI工作流引擎,提供了AI代理运行时治理和安全监控功能
该工具使用 NOASSERTION 协议,商用场景请仔细阅读协议条款,必要时咨询法律意见。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
📄 NOASSERTION — 请查阅原始协议条款了解具体使用限制。
经综合评估,SAFi 在Agent工作流赛道中表现稳健,质量良好。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | SAFi |
| 原始描述 | 开源AI工作流:SAFi is an open‑source runtime governance engine for AI agents. Built for IT Dir。⭐43 · Python |
| Topics | aiai-governanceai-safetyethics |
| GitHub | https://github.com/jnamaya/SAFi |
| License | NOASSERTION |
| 语言 | Python |
收录时间:2026-05-27 · 更新时间:2026-05-30 · License:NOASSERTION · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端