InfinitiBit/graphbit
GitHub: InfinitiBit/graphbit
GraphBit 是一个基于 Rust 核心的企业级多智能体 AI 框架,通过 Python API 提供类型安全、高可靠性的工作流编排能力。
Stars: 524 | Forks: 108
**阅读其他语言版本**:[🇨🇳 简体中文](README_Multi_Lingual_i18n_Files/README.zh-CN.md) | [🇨🇳 繁體中文](README_Multi_Lingual_i18n_Files/README.zh-TW.md) | [🇪🇸 Español](README_Multi_Lingual_i18n_Files/README.es.md) | [🇫🇷 Français](README_Multi_Lingual_i18n_Files/README.fr.md) | [🇩🇪 Deutsch](README_Multi_Lingual_i18n_Files/README.de.md) | [🇯🇵 日本語](README_Multi_Lingual_i18n_Files/README.ja.md) | [🇰🇷 한국어](README_Multi_Lingual_i18n_Files/README.ko.md) | [🇮🇳 हिन्दी](README_Multi_Lingual_i18n_Files/README.hi.md) | [🇸🇦 العربية](README_Multi_Lingual_i18n_Files/README.ar.md) | [🇮🇹 Italiano](README_Multi_Lingual_i18n_Files/README.it.md) | [🇧🇷 Português](README_Multi_Lingual_i18n_Files/README.pt-BR.md) | [🇷🇺 Русский](README_Multi_Lingual_i18n_Files/README.ru.md) | [🇧🇩 বাংলা](README_Multi_Lingual_i18n_Files/README.bn.md)
GraphBit 是一个开源的智能体 AI 框架,用于确定性、并发、低开销的执行。
## 为什么选择 GraphBit?
Grant Thornton Germany adopted GraphBit to move AI from "permanent pilot" to production without regulatory risk as a core component of their tech stack.
## 关键特性
- **工具选择** - LLM 根据描述智能选择工具
- **类型安全** - 贯穿每个执行层的强类型
- **可靠性** - 断路器、重试策略、错误处理和故障恢复
- **多 LLM 支持** - OpenAI, Azure OpenAI, Anthropic, OpenRouter, DeepSeek, Replicate, Ollama, TogetherAI 等
- **资源管理** - 并发控制和内存优化
- **可观测性** - 内置追踪、结构化日志和性能指标
## 基准测试
GraphBit 是为规模化效率而构建的,不是基于理论声明,而是基于实际测量结果。
我们的内部基准测试套件在相同负载下将 GraphBit 与主流的 Python 智能体框架进行了比较。
| 指标 | GraphBit | 其他框架 | 提升 |
|:--------------------|:---------------:|:----------------:|:-------------------------|
| CPU 使用率 | 1.0× 基线 | 高 68.3× | ~68× CPU |
| 内存占用 | 1.0× 基线 | 高 140× | ~140× 内存 |
| 执行速度 | ≈ 相等 / 更快| — | 稳定的吞吐量 |
| 确定性 | 100% 成功 | 不稳定 | 保证可靠性 |
GraphBit 在 LLM 调用、工具调用和多智能体链中始终提供生产级的效率。
### 基准测试演示
## 何时使用 GraphBit
如果您需要以下特性,请选择 GraphBit:
- 在高负载下不会崩溃的生产级多智能体系统
- 类型安全的执行和可复现的输出
- 针对混合或流式 AI 应用的实时编排
- 具备 Python 级易用性的 Rust 级效率
如果您正在扩展超越原型的项目,或者关心运行时的确定性,GraphBit 就是您的理想选择。
## 快速开始
### 安装
建议使用虚拟环境。
```
pip install graphbit
```
### 快速入门视频教程
### 环境设置
在项目中设置您想使用的 API keys:
```
# OpenAI(可选 – 如使用 OpenAI models 则必需)
export OPENAI_API_KEY=your_openai_api_key_here
# Anthropic(可选 – 如使用 Anthropic models 则必需)
export ANTHROPIC_API_KEY=your_anthropic_api_key_here
```
### 基本用法
```
import os
from graphbit import LlmConfig, Executor, Workflow, Node, tool, GuardRailPolicyConfig
# 初始化并配置
config = LlmConfig.openai(os.getenv("OPENAI_API_KEY"), "gpt-4o-mini")
# 创建 executor
executor = Executor(config)
# 创建带有清晰描述的工具供 LLM 选择
@tool(_description="Get current weather information for any city")
def get_weather(location: str) -> dict:
return {"location": location, "temperature": 22, "condition": "sunny"}
@tool(_description="Perform mathematical calculations and return results")
def calculate(expression: str) -> str:
return f"Result: {eval(expression)}"
# 构建 workflow
workflow = Workflow("Analysis Pipeline")
# 创建 agent 节点
smart_agent = Node.agent(
name="Smart Agent",
prompt="What's the weather in Paris and calculate 15 + 27?",
system_prompt="You are an assistant skilled in weather lookup and math calculations. Use tools to answer queries accurately.",
tools=[get_weather, calculate]
)
processor = Node.agent(
name="Data Processor",
prompt="Process the results obtained from Smart Agent.",
system_prompt="""You process and organize results from other agents.
- Summarize and clarify key points
- Structure your output for easy reading
- Focus on actionable insights
"""
)
# 连接并执行
id1 = workflow.add_node(smart_agent)
id2 = workflow.add_node(processor)
workflow.connect(id1, id2)
# 运行(可选配合 guardrail policy 进行 PII masking/mapping)
result = executor.execute(workflow)
# 或者使用 policy:result = executor.execute(workflow, policy=GuardRailPolicyConfig.from_json('{"guardrail_policy": {"pii_rules": [...]}}'))
print(f"Workflow completed: {result.is_success()}")
print("\nSmart Agent Output: \n", result.get_node_output("Smart Agent"))
print("\nData Processor Output: \n", result.get_node_output("Data Processor"))
```
### 使用 GraphBit 构建您的第一个智能体工作流
## 可观测性与追踪
GraphBit Tracer 以极简的配置捕获和监控 LLM 调用及 AI 工作流。它封装了 GraphBit LLM 客户端和工作流执行器,以追踪提示、响应、token 使用情况、延迟和错误,无需修改您的代码。
## 高层架构
Grant Thornton Germany adopted GraphBit to move AI from "permanent pilot" to production without regulatory risk as a core component of their tech stack.
标签:Agentic AI, AI智能体, AI风险缓解, GraphBit, LLM框架, PyRIT, Python, Rust, 人工智能框架, 企业级AI, 低资源消耗, 可视化界面, 多智能体系统, 大模型开发, 威胁情报, 工作流自动化, 开发者工具, 无后门, 测试用例, 生产就绪, 网络流量审计, 逆向工具, 通知系统, 高性能计算