{"id":16834566,"url":"https://github.com/yuruotong1/xbrain","last_synced_at":"2025-04-09T06:12:23.310Z","repository":{"id":257815995,"uuid":"869884502","full_name":"yuruotong1/xbrain","owner":"yuruotong1","description":"通过装饰器将函数接入OpenAI的Chat","archived":false,"fork":false,"pushed_at":"2025-03-09T14:06:19.000Z","size":8065,"stargazers_count":43,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T09:37:00.485Z","etag":null,"topics":["agent","ai","aigc","autogen","autogpt","dify","langchain"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuruotong1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-09T04:13:23.000Z","updated_at":"2025-03-09T14:06:22.000Z","dependencies_parsed_at":"2025-03-26T02:02:56.440Z","dependency_job_id":"217bcaef-c1c8-47f7-9734-5e2bd5f6c2f3","html_url":"https://github.com/yuruotong1/xbrain","commit_stats":null,"previous_names":["yuruotong1/xbrain"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuruotong1%2Fxbrain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuruotong1%2Fxbrain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuruotong1%2Fxbrain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuruotong1%2Fxbrain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuruotong1","download_url":"https://codeload.github.com/yuruotong1/xbrain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","aigc","autogen","autogpt","dify","langchain"],"created_at":"2024-10-13T12:06:25.893Z","updated_at":"2025-04-09T06:12:23.287Z","avatar_url":"https://github.com/yuruotong1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003ca name=\"readme-top\"\u003e\n\n\u003cimg src=\"./image/README/logo.png\" width=\"120\" height=\"120\" alt=\"XBrain\"\u003e\n\u003ch1\u003eXBrain\u003c/h1\u003e\n\n通过装饰器将函数接入OpenAI的Chat\n\n📘[详细文档](https://xbrain.notion.site/)|🎞️[介绍视频](https://www.bilibili.com/video/BV1c52FY4E51/?share_source=copy_web\u0026vd_source=c28e503b050f016c21660b69e391d391)|🗨[English](https://github.com/yuruotong1/xbrain/blob/master/README_EN.md)\n\n\u003c/div\u003e\n\n## 🤔解决了什么问题\n\nOpenAI的Funciton Call很有用，但每次都需要在 chat 接口中引用Json或者Pydantic Model，而XBrain只需要在Python函数上放一个装饰器，就能自动将函数接入到 chat 中。\n\n\n## 📄文档\n\n- [快速开始：新手上手指南，适合第一次接触的开发者](https://xbrain.notion.site/xbrain-11d42182d0a98003b272d5555c6e9448)\n- [常见问题：你想知道的答案都在这里](https://xbrain.notion.site/b274c33d808a4ddea32244c3fd41719c)\n- [开发者指南：欢迎加入我们](https://xbrain.notion.site/12842182d0a9803bb5dcdbfe71826915?pvs=4)\n\n## Quick Start\n\n安装xbrain:\n\n`pip install pyxbrain`\n\n在你的项目目录下创建一个`demo.py`文件，写入以下代码：\n\n```python\nfrom pydantic import BaseModel\nfrom xbrain.core import xbrain_tool\nclass GenerateTag(BaseModel):\n    \"\"\"创建一个新的插件\"\"\"\n    pass\n\n@xbrain_tool.Tool(model=GenerateTag)\ndef generate_tag():\n    print(\"hello\")\n```\n\n在`__init__.py`文件中导入`demo.py`：\n\n```python\nfrom demo import *\n```\n\n在项目入口处配置并运行xbrain，此时`demo.py`中的`generate_tag`函数被成功接入了xbrain中：\n\n```python\nfrom xbrain.core.chat import run \nfrom xbrain.utils.config import Config\nconfig = Config()\nconfig.set_openai_config(base_url=\"https://api.openai-next.com/v1\", api_key=\"xxxxx\", model=\"gpt-4o-2024-08-06\")\nmessages = []\nmessages.append({\"role\": \"user\", \"content\": \"配置tag\"})\nres = run(messages, user_prompt=\"从文章中提炼出关键信息\")\n```\n\n## 🤝 如何贡献\n\n你可以通过 Fork 项目、提交 PR 或在 Issue 中提出你的想法和建议。具体操作可参考[贡献指南](https://xbrain.notion.site/12842182d0a9803bb5dcdbfe71826915)。\n\n\n\u003e 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393)，更好的问题更容易获得帮助。\n\n\u003ca href=\"https://github.com/yuruotong1/xbrain/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=yuruotong1/xbrain\" /\u003e\n\u003c/a\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuruotong1%2Fxbrain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuruotong1%2Fxbrain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuruotong1%2Fxbrain/lists"}