XBrain 是一个让 Python 函数变身为 AI 驱动的 HTTP 服务的超级智能体
Project description
🤔解决了什么问题
OpenAI的Funciton Call很有用,但每次都需要在 chat 接口中引用Json或者Pydantic Model,而XBrain只需要在Python函数上放一个装饰器,就能自动将函数接入到 chat 中。
📄文档
Quick Start
安装xbrain:
pip install pyxbrain
在你的项目目录下创建一个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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyxbrain-1.1.25.tar.gz.
File metadata
- Download URL: pyxbrain-1.1.25.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86ad2564f47f3252d02eca9ef064670e45ecd3111681a807b233d061c749ec42
|
|
| MD5 |
0b905db5c35eda6c9098d3f0221e3020
|
|
| BLAKE2b-256 |
e7366b2c89425ab32ea0219e6281c23e3efadee46e29a9b1b5a086ec85610283
|
File details
Details for the file pyxbrain-1.1.25-py3-none-any.whl.
File metadata
- Download URL: pyxbrain-1.1.25-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
275b5cc82fbae075358bebed81b1e8e5a2f7aa99c13c1135c83df4ad58f48581
|
|
| MD5 |
2a1cbf69f6933358e6963997bd16f749
|
|
| BLAKE2b-256 |
9819551fec2b80c801de5e06e60d4f4ed3c70f88907c8f95bf8ac644a53419bb
|