Skip to main content

XBrain 是一个让 Python 函数变身为 AI 驱动的 HTTP 服务的超级智能体

Project description

🤔解决了什么问题

如果你用LangChain开发Agent应用,需要以下四步:

  1. 基础组件设置
  2. 定义工具集
  3. 定义Prompt模板
  4. 定义输出解析器

如果你用swarm开发Agent应用,需要以下四步:

  1. 基础组件设置
  2. Agent角色定义
  3. 任务协调系统
  4. 工作流程实现

但是,如果你用xbrain开发Agent应用,一切将变得非常美好,只需要两步:

  1. 编写工具
  2. 与AI聊天部署运行

👥用户故事

  • AI 接口封装: 独立 AI 函数快速封装为 HTTP 服务,便于集成到其他系统中;
  • 功能验证: 早期开发阶段原型设计与测试,无需搭建复杂后端;
  • 轻量化微服务改造: 适合将 Python 脚本微服务化,轻松满足小规模、灵活部署需求。

✨特点

  • 一键安装,开箱即用: 命令行一键启动,简单易用;
  • 无提示词设计: 摒弃提示词书写,用户专注于业务开发;
  • 将python函数接入Tools Call: 将本地 Python 代码直接接入大模型的工具调用。

📄文档

Quick Start

在你的项目目录下创建一个demo.py文件,写入以下代码:

from pydantic import BaseModel
from xbrain.core import xbrain_tool
class GenerateTag(BaseModel):
    """创建一个新的插件"""
    pass

@xbrain_tool.Tool(model=GenerateTag)
def generate_tag():
    print("hello")

`__init__.py`文件中导入`demo.py`:
```python
from .demo import *

在项目入口处配置并运行xbrain,此时demo.py中的generate_tag函数被成功接入了xbrain中:

from xbrain.core.chat import run 
from xbrain.utils.config import Config
config = Config()
config.set_openai_config(base_url="https://api.openai-next.com/v1", api_key="xxxxx", model="gpt-4o-2024-08-06")
messages = []
messages.append({"role": "user", "content": "配置tag"})
res = run(messages, user_prompt="从文章中提炼出关键信息")

🤝 如何贡献

你可以通过 Fork 项目、提交 PR 或在 Issue 中提出你的想法和建议。具体操作可参考贡献指南

强烈推荐阅读 《提问的智慧》《如何向开源社区提问题》《如何有效地报告 Bug》《如何向开源项目提交无法解答的问题》,更好的问题更容易获得帮助。

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

pyxbrain-1.1.24.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

pyxbrain-1.1.24-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file pyxbrain-1.1.24.tar.gz.

File metadata

  • Download URL: pyxbrain-1.1.24.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for pyxbrain-1.1.24.tar.gz
Algorithm Hash digest
SHA256 f902fa44e4146f530a837c42f073d5be979c101d4c5d4cbdad4396985451f56d
MD5 8b7b45a112a23a7280b91ff3233c3576
BLAKE2b-256 cf84e9a68ca2a5c449205985bb9d12ab1fdf1f125140c9c58992fdd42edd6e88

See more details on using hashes here.

File details

Details for the file pyxbrain-1.1.24-py3-none-any.whl.

File metadata

  • Download URL: pyxbrain-1.1.24-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.11

File hashes

Hashes for pyxbrain-1.1.24-py3-none-any.whl
Algorithm Hash digest
SHA256 28b48395b415fbc268ad16b83f85acaa87024f75aadc32e152b44160d7988dee
MD5 19bf75d1173c70cb9df69a848f534b00
BLAKE2b-256 5c01145278315417461ab5d60250eb194a6a654fce329d2c3102bbc5fad9bcc8

See more details on using hashes here.

Supported by

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