Skip to main content

xbrain专注于构建一款可解释的AI开发框架

Project description

✨特点

  1. 屏蔽了提示词,让用户专注于业务开发:用户无需编写提示词,就能开发大模型应用;
  2. 用自然语言开发function call:通过自然语言将本地的python代码接入到openai的function call。

文档

几个有意思的例子

将任何加减操作映射成两数相加

通过xb定义一个加法函数:

I guess you want to do the following, or chat with me:

1. chat with my action
2. create a new action
3. deploy a chat server
4. integrate existing functions into xbrain

>>> 2
Please tell me, the action you want to do?
>>> 两数相加
Please wait a moment, I'm generating the code for you...
Creation successful!
file generated:  C:\Users\yuruo\Desktop\test2\add_action.py

add_action.py文件的内容:

from xbrain import xbrain_tool
from pydantic import BaseModel, Field

class Add(BaseModel):
    """Add two numbers"""
    a: int = Field(..., description="First number")
    b: int = Field(..., description="Second number")

@xbrain_tool.Tool(model=Add)
def add(a: int, b: int) -> int:
    """
    Add two numbers.
    """
    return a + b

通过xbrain的chat mode可以实现两数相加:

I guess you want to do the following, or chat with me:

1. chat with my action
2. create a new action
3. deploy a chat server
4. integrate existing functions into xbrain

>>> 1
Welcome to chat mode!
💬 1+1
run action
 action name:  Add
 action path:  C:\Users\yuruo\Desktop\test2\add_action.py
 action arguments:  {'a': 1, 'b': 1}
 action result:  2

2

然而它也能实现两数相减:

💬 1-1
run action
 action name:  Add
 action path:  C:\Users\yuruo\Desktop\test2\add_action.py
 action arguments:  {'a': 1, 'b': -1}
 action result:  0

0

它还能实现三数相加减,虽然结果不对但我们看到了它的尝试,这也是我们优化的方向:

💬 1+1+3
run action
 action name:  Add
 action path:  C:\Users\yuruo\Desktop\test2\add_action.py
 action arguments:  {'a': 1, 'b': 1}
 action result:  2

run action
 action name:  Add
 action path:  C:\Users\yuruo\Desktop\test2\add_action.py
 action arguments:  {'a': 1, 'b': 3}
 action result:  4

2
4

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.7.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

pyxbrain-1.1.7-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyxbrain-1.1.7.tar.gz
  • Upload date:
  • Size: 11.2 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.7.tar.gz
Algorithm Hash digest
SHA256 6c631a267c9705351101fe5510d699170c3943956975e32d0b37171d12ae454e
MD5 5a54b0270692d35233083cffff589ea0
BLAKE2b-256 506d6c81efbcba23f88ad71a02ca8f410a6e85acb25092fbfa7277b027a1f0d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyxbrain-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 15.5 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 76c56acc927200d3611714ab4b2efb95ca31f5e1723fd7cd1c6f18e76360e9f0
MD5 9a604c59b1fbd64581b08fcf63d53b1c
BLAKE2b-256 3b14a3f4cd7e1565af34e83c9184a86eeca4436fd604c3566746059b6810ab9c

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