Skip to main content

基于 LangGraph + LLM 的通用 Agent 编排框架

Project description

Flux-Agent

基于 LangGraph + LLM 的通用 Agent 编排框架。通过 JSON 配置文件即可启动多 Agent Node 工作流,支持复杂的自动化流程编排。

核心特性

  • JSON 配置驱动 - 无需编写代码,通过 JSON 配置即可定义复杂工作流
  • 内置通用节点 - LLM 调用、条件分支、工具调用、HTTP 请求等开箱即用
  • 可插拔扩展 - 用户可按规范开发自定义节点,注册即可使用
  • 并行执行 - 原生支持 map-reduce、并行处理等模式
  • 人工介入 - 支持工作流暂停、人工审核、断点恢复
  • 子图嵌套 - 支持将工作流作为子图嵌入其他工作流
  • 状态持久化 - 支持内存、SQLite、PostgreSQL 等多种存储后端

快速开始

安装

pip install flux-agent

最简示例

from flux_agent import WorkflowRunner

# 从 JSON 配置加载工作流
runner = WorkflowRunner("workflow.json")

# 执行
result = runner.invoke({"user_input": "你好"})
print(result)

JSON 配置示例

{
  "workflow": {
    "name": "simple-chain",
    "description": "简单的 LLM 调用链"
  },
  "nodes": [
    {
      "id": "greet",
      "type": "LLMNode",
      "config": {
        "model": "openai",
        "model_name": "gpt-4o",
        "system_prompt": "你是一个友好的助手",
        "user_prompt": "${data.user_input}",
        "output_key": "data.response"
      }
    }
  ],
  "edges": [
    {"from": "START", "to": "greet"},
    {"from": "greet", "to": "END"}
  ]
}

内置节点

节点类型 功能 说明
LLMNode LLM 调用 支持 OpenAI、Anthropic、Gemini 等
ConditionNode 条件分支 if/else、switch 分支路由
ToolNode 工具调用 执行预定义的工具/函数
TransformNode 数据转换 set/get/filter/map 等操作
LoopNode 循环执行 for/while 循环控制
ParallelNode 并行执行 map-reduce 模式
HTTPRequestNode HTTP 调用 REST API 调用
SubgraphNode 子图嵌套 嵌入其他工作流
HumanInputNode 人工介入 暂停等待人工输入

文档

项目结构

flux-agent/
├── flux_agent/               # 包目录
│   ├── core/                 # 核心引擎
│   │   ├── state.py          # 状态模型
│   │   ├── registry.py       # 节点注册表
│   │   ├── parser.py         # 配置解析器
│   │   └── executor.py       # 执行引擎
│   │
│   ├── nodes/                # 节点模块
│   │   ├── base/             # 基类层
│   │   │   ├── node.py       # 节点基类
│   │   │   ├── config.py     # 配置模型
│   │   │   └── interfaces.py # 接口协议
│   │   ├── builtin/          # 内置节点
│   │   │   ├── control/      # condition, loop
│   │   │   ├── llm/          # LLM 调用
│   │   │   ├── transform/    # 数据转换
│   │   │   └── io/           # http, tool, parallel, subgraph, human
│   │   ├── examples/         # 示例节点
│   │   └── business/         # 业务节点
│   │
│   ├── utils/                # 工具函数
│   │   └── expression.py     # 表达式解析
│   │
│   └── tools/                # 工具模块
│
├── examples/                 # 示例脚本(不发布)
│   ├── demo_*.py
│   └── *.json
│
├── docs/                     # 文档(不发布)
│   ├── TECHNICAL.md          # 技术架构
│   ├── USAGE.md              # 使用指南
│   ├── NODE_DEVELOPMENT.md   # 节点开发
│   ├── EXTERNAL_NODES.md     # 外部节点注册
│   └── CONFIG_REFERENCE.md   # 配置参考
│
├── pyproject.toml            # 包配置
├── LICENSE                   # MIT License
├── CHANGELOG.md              # 变更日志
└── README.md

依赖

  • Python >= 3.10
  • langgraph >= 0.3
  • langchain-core >= 0.3
  • pydantic >= 2.0

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flux_agent-0.1.1.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flux_agent-0.1.1-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

Details for the file flux_agent-0.1.1.tar.gz.

File metadata

  • Download URL: flux_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for flux_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d122283171551da8ad34b3bfb81892cf2af784b3bf83e6a06d0f4300e06a46ab
MD5 667c8cc92cfd926ba755ca9e8bd530ee
BLAKE2b-256 1f68d91b4528e0d979faa40df1a9d763768ab3a74b332e0b16b61ff600d61bb2

See more details on using hashes here.

File details

Details for the file flux_agent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: flux_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for flux_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28d4fc096ef2d3571e51943c273d9a0b10b7b9cb65f5a25c0986c89ab8e27ec0
MD5 bd60f767098505e6266bfe0a5f48f197
BLAKE2b-256 36f073f1ff1ee394e60dffab53e842f77247f3f3283427dff31d276071fe55a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page