Skip to main content

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

Project description

Flux-Agent

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

核心特性

  • JSON 配置驱动 - 无需编写代码,通过 JSON 配置即可定义复杂工作流
  • 内置通用节点 - LLM 调用、条件分支、工具调用、HTTP 请求等开箱即用
  • RAG 能力 - 知识库管理、向量检索、检索增强生成
  • 多模态支持 - 支持图片、视频输入
  • 可插拔扩展 - 用户可按规范开发自定义节点,注册即可使用
  • 并行执行 - 原生支持 map-reduce、并行处理等模式
  • 人工介入 - 支持工作流暂停、人工审核、断点恢复
  • 子图嵌套 - 支持将工作流作为子图嵌入其他工作流

快速开始

安装

pip install flux-agent

RAG 知识库创建

from flux_agent.rag import (
    KnowledgeBase,
    KnowledgeBaseConfig,
    KnowledgeChunkConfig,
    KnowledgeEmbeddingConfig,
)

config = KnowledgeBaseConfig(
    name="my_docs",
    persist_directory="./kb_data/my_docs",
    embedding_config=KnowledgeEmbeddingConfig(
        model="text-embedding-3-small",
    )
)

kb = KnowledgeBase.create(name="my_docs", config=config)
kb.add_texts(["知识库内容..."])
kb.generate()

工作流执行

from flux_agent import WorkflowRunner

runner = WorkflowRunner("workflow.json")
result = runner.invoke({"data": {"input": "你好"}})
print(result)

JSON 配置示例

{
  "nodes": [
    {
      "id": "llm",
      "type": "llm",
      "config": {
        "model_name": "gpt-4o",
        "system_prompt": "你是一个助手",
        "user_prompt": "${data.input}"
      }
    }
  ],
  "edges": [
    {"from": "START", "to": "llm"},
    {"from": "llm", "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 人工介入 暂停等待人工输入
RagSearchNode RAG 检索 知识库向量检索

文档

项目结构

flux-agent/
├── flux_agent/               # 包目录
│   ├── core/                 # 核心引擎
│   │   ├── executor.py       # 执行引擎
│   │   ├── parser.py         # 配置解析器
│   │   ├── registry.py       # 节点注册表
│   │   └── state.py          # 状态模型
│   │
│   ├── nodes/                # 节点模块
│   │   ├── base/             # 基类层
│   │   │   ├── node.py       # 节点基类
│   │   │   └── config.py     # 配置模型
│   │   ├── builtin/          # 内置节点
│   │   │   ├── control/      # condition, loop
│   │   │   ├── llm/          # LLM 调用(支持多模态)
│   │   │   ├── rag/          # RagSearchNode
│   │   │   ├── transform/    # 数据转换
│   │   │   └── io/           # http, tool, parallel, subgraph, human
│   │   └── ...
│   │
│   ├── rag/                  # RAG 模块
│   │   ├── knowledge_base.py # 知识库管理
│   │   ├── document_loader.py # 文档加载
│   │   ├── embeddings.py    # Embedding
│   │   └── vector_store.py  # 向量存储
│   │
│   ├── utils/                # 工具函数
│   │   └── expression.py     # 表达式解析
│   │
│   └── tools/                # 工具模块
│
├── examples/                 # 示例脚本
│   ├── rag/                 # RAG 示例
│   └── demo_*.py
│
├── docs/                     # 文档
│   ├── RAG.md               # RAG 模块指南
│   ├── USAGE.md             # 使用指南
│   ├── TECHNICAL.md         # 技术架构
│   └── ...
│
├── pyproject.toml            # 包配置
├── CHANGELOG.md              # 变更日志
└── README.md

依赖

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

可选依赖:

  • faiss-cpu - FAISS 向量存储

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.2.1.tar.gz (48.0 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.2.1-py3-none-any.whl (61.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flux_agent-0.2.1.tar.gz
  • Upload date:
  • Size: 48.0 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.2.1.tar.gz
Algorithm Hash digest
SHA256 354d60527155c80efca50b9da14cf2d158b61aa31003b17a466c7d22d055b721
MD5 32ba3cf25236ee9f408f915f64d35455
BLAKE2b-256 a6d032c99efb7a4c0964d2ca472a1b72b98890dffa22d123cef4a58b7783808d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flux_agent-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 61.2 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6645eb7c1c86171e2163c011e0c7858f378557af229d798a3ad0d2d02e7e902d
MD5 8dcf7f1d82106e6646d32081235efdfd
BLAKE2b-256 b2a4b751e19fdff05d55e3b71a775d79dc560e139f6637eeb50d048f11b98bf6

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