Metadata-Version: 2.1
Name: llmkira
Version: 0.27.2
Summary: A chain message bot based on OpenAI
Home-page: https://llmkira.github.io/Docs/
License: Apache-2.0
Keywords: llmbot,llmkira,openai,chatgpt,telegram,bot
Author: llmkira
Author-email: me@dianas.cyou
Requires-Python: >=3.8,<3.12
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Provides-Extra: all
Provides-Extra: bot
Requires-Dist: aio-pika (>=9.3.0,<10.0.0)
Requires-Dist: aiohttp (>=3.8.6,<4.0.0)
Requires-Dist: apscheduler (>=3.10.4,<4.0.0)
Requires-Dist: arclet-alconna (>=1.7.26,<2.0.0)
Requires-Dist: boltons (>=23.1.1,<24.0.0)
Requires-Dist: cjieba (>=0.4.4,<0.5.0)
Requires-Dist: contextvars (>=2.4,<3.0)
Requires-Dist: docstring-parser (>=0.15,<0.16)
Requires-Dist: dynaconf (>=3.2.3,<4.0.0)
Requires-Dist: elara (>=0.5.5,<0.6.0)
Requires-Dist: emoji (>=2.8.0,<3.0.0)
Requires-Dist: fasttext-wheel (>=0.9.2,<0.10.0)
Requires-Dist: feedparser (>=6.0.10,<7.0.0)
Requires-Dist: ffmpeg-python (>=0.2.0,<0.3.0)
Requires-Dist: flask-sqlalchemy (>=3.1.1,<4.0.0)
Requires-Dist: hikari (>=2.0.0.dev121,<3.0.0) ; extra == "bot" or extra == "all"
Requires-Dist: hikari-crescent (>=0.6.4,<0.7.0) ; extra == "bot" or extra == "all"
Requires-Dist: httpx (==0.24.1)
Requires-Dist: importlib-metadata (>=6.8.0,<7.0.0)
Requires-Dist: inscriptis (>=2.3.2,<3.0.0)
Requires-Dist: jieba (>=0.42.1,<0.43.0)
Requires-Dist: khl-py (>=0.3.17,<0.4.0) ; extra == "bot" or extra == "all"
Requires-Dist: loguru (>=0.5.3)
Requires-Dist: motor (>=3.3.1,<4.0.0)
Requires-Dist: nest-asyncio (>=1.5.8,<2.0.0)
Requires-Dist: nltk (>=3.8.1,<4.0.0)
Requires-Dist: numpy (>=1.24.0,<2.0.0)
Requires-Dist: orjson (>=3.9.10,<4.0.0)
Requires-Dist: pathlib (>=1.0.1)
Requires-Dist: pillow (>=10.1.0,<11.0.0)
Requires-Dist: polling (>=0.3.2,<0.4.0)
Requires-Dist: pydantic (>=2.0.0)
Requires-Dist: pydantic-settings (>=2.0.3,<3.0.0)
Requires-Dist: pysocks (>=1.7.1,<2.0.0)
Requires-Dist: pytelegrambotapi (>=4.14.0,<5.0.0)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: pytz (>=2023.3.post1,<2024.0)
Requires-Dist: redis (>=4.5.4)
Requires-Dist: requests[socks] (>=2.31.0,<3.0.0)
Requires-Dist: rich (>=13.6.0,<14.0.0)
Requires-Dist: scikit-learn (>=1.3.2,<2.0.0)
Requires-Dist: sentry-sdk (>=1.34.0,<2.0.0)
Requires-Dist: shortuuid (>=1.0.11,<2.0.0)
Requires-Dist: slack-bolt (>=1.18.0,<2.0.0) ; extra == "bot" or extra == "all"
Requires-Dist: socksio (>=1.0.0,<2.0.0)
Requires-Dist: tenacity (>=8.2.3,<9.0.0)
Requires-Dist: tiktoken (>=0.5.1,<0.6.0)
Requires-Dist: tzlocal (>=5.2,<6.0)
Requires-Dist: unstructured[docx,pptx] (>=0.10.30,<0.11.0)
Requires-Dist: websocket (>=0.2.1,<0.3.0)
Requires-Dist: wrapt (>=1.11.0,<2.0.0)
Project-URL: Repository, https://github.com/LlmKira/Openaibot
Description-Content-Type: text/markdown

![cover](https://raw.githubusercontent.com/LlmKira/.github/main/llmbot/project_cover.png)

------------------

<p align="center">
<a href="https://hub.docker.com/repository/docker/sudoskys/llmbot/general">
    <img src="https://img.shields.io/docker/pulls/sudoskys/llmbot" alt="docker">
</a>
<a href="https://github.com/llmkira/openaibot/actions/workflows/docker-ci.yaml">
    <img src="https://github.com/llmkira/openaibot/actions/workflows/docker-ci.yaml/badge.svg" alt="docker workflow">
</a>
<br />
<a href="https://t.me/Openai_LLM">
    <img src="https://img.shields.io/badge/Join-Telegram-blue" alt="telegram">
</a>
<a href="https://discord.gg/6QHNdwhdE5">
    <img src="https://img.shields.io/badge/Join-Discord-blue" alt="discord">
</a>
<br/>
<a href="https://raw.githubusercontent.com/llmkira/openaibot/main/LICENSE">
    <img src="https://img.shields.io/github/license/llmkira/openaibot" alt="license">
</a>
<a href="https://hub.docker.com/repository/docker/sudoskys/llmbot/builds">
    <img src="https://img.shields.io/docker/v/sudoskys/llmbot" alt="docker build">
</a>
</p>

<p align="center">
  <a href="https://llmkira.github.io/Docs/">🍩 部署文档</a> 
  &
  <a href="https://llmkira.github.io/Docs/dev/basic">🧀 开发文档</a>
  &
  <a href="README_EN.md">📝 English Readme</a>
  &
  <a href="CONTRIBUTING.md">🤝 贡献必看</a>
</p>


> **Look for English README? Click [here](README_EN.md). We also have English
documentation [here](https://llmkira.github.io/Docs/en).**

> 部署遇到问题？提交 Issue 帮助我们提升可用性

此项目为自部署，实用可扩展的机器人核心，以 `FunctionCall` `ToolCall` 为核心，支持多种消息平台。

采用消息队列，很好处理函数请求，支持繁杂的插件和功能设计。良好支持文件系统。

支持多种模型源，支持跨平台消息转发。

| Demo                              |
|-----------------------------------| 
| ![sticker](./docs/chain_chat.gif) | 

与之前的项目不同的是，此项目尝试基于消息平台复刻 ChatGpt 的插件系统，实现部分或更进一步的功能。

> 因为 func call 为 feature,所以只支持 Openai 类型的 api, 不打算支持没有 func call 的 LLM

## 📦 Feature

- 🍪 完善的插件开发生态，采用经典设计，通过 `pip` 安装即可使用
- 📝 消息系统，不限时间，不限发送端，定义发送接收者，逻辑完全解耦
- 📎 路由消息，自定义消息路由，以路由决定运作方式
- 📬 公共开放限额/私人自配置后端/代理Token认证，提供灵活可扩展的鉴权开发方案
- 🍾 支持中间件拦截开发，开发扩展即可操作流程前后数据
- 🎵 细化的统计系统，轻松统计使用情况
- 🍰 支持插件人在回路验证，可鉴权，可设置插件黑名单
- 📦 完善标准的文件交互支持，上传/下载文件
- 🍖 支持个人单独配置环境密钥，为插件提供个人的私有环境变量
- 🍟 支持大语言模型增量支持，支持多平台扩展，继承标准类即可适配
- 🍔 同时支持 `FunctionCall` `ToolCall` 特性，根据模型动态构建需要的函数类

### 🧀 部分插件预览

| Sticker Converter                   | Timer Func                      | Translate Func                               |
|-------------------------------------|---------------------------------|----------------------------------------------|
| ![sticker](./docs/sticker_func.gif) | ![timer](./docs/timer_func.gif) | ![translate](./docs/translate_file_func.gif) |

### 🧀 认证系统介绍

我们采用的认证系统称为 `Service Provider`，即服务提供商，它的作用是为每个发送者分配 Endpoint/Key/Model ，用于鉴权。
拥有一个 `token` 作为绑定的 OpenKey。程序会调用设定的 `Service Provider` 读取私有 Key/配置 Token 来获取鉴权信息。

![auth](./docs/SeriveProvider.svg)

认证组件和后端均需要自行实现。

### 🎬 平台支持

| 平台       | 支持情况 | 文件系统 | 备注          |
|----------|------|------|-------------|
| Telegram | ✅    | ✅    |             |
| Discord  | ✅    | ✅    |             |
| Kook     | ✅    | ✅    | 不支持 `被回复启动` |
| Slack    | ✅    | ✅    | 不支持 `被回复启动` |
| QQ       | ❌    |      |             |
| Wechat   | ❌    |      |             |
| Twitter  | ❌    |      |             |
| Matrix   | ❌    |      |             |
| IRC      | ❌    |      |             |
| ...      |      |      | 创建Issue/PR  |

## 📦 快速开始

阅读 [🧀 部署文档](https://llmkira.github.io/Docs/) 获得更多信息。

请提前用 `python3 start_sender.py`  `python3 start_receiver.py` 测试是否能正常运行。

#### 性能指标测试(Until 2023/11/1)

注意，不包括pm2，redis，rabbitmq，mongodb，docker等服务的内存占用。

| 进程         | 内存均值      | 测算命令                                             | client   |
|------------|-----------|--------------------------------------------------|----------|
| `receiver` | 120.202MB | `python3 -m memray run --live start_receiver.py` | telegram |
| `sender`   | 83.375MB  | `python3 -m memray run --live start_sender.py`   | telegram |

### 🥣 Docker

Build Hub: [sudoskys/llmbot](https://hub.docker.com/repository/docker/sudoskys/llmbot/general)

#### 自动 Docker/Docker-compose安装

如果你在使用一台崭新的服务器，你可以使用下面的Shell来尝试自动安装本项目。

此脚本会自动使用 Docker 方法安装所需服务并映射端口，如果您已经部署了 `redis` ，`rabbitmq` ，`mongodb` 。

请自行修改 `docker-compose.yml` 文件。

```shell

curl -sSL https://raw.githubusercontent.com/LLMKira/Openaibot/main/deploy.sh | bash
```

#### 手动 Docker-compose安装

```shell
git clone https://github.com/LlmKira/Openaibot.git
cd Openaibot
cp .env.exp .env&&nano .env
docker-compose -f docker-compose.yml up -d

```

更新镜像使用 `docker-compose pull`。

在 docker 中查看 Shell，使用 `docker exec -it llmbot /bin/bash`，输入 `exit` 退出。

### 🍔 Shell

人工使用Pm2启动，需要自行安装 `redis` ，`rabbitmq` ，`mongodb` 。

```shell
git clone https://github.com/LlmKira/Openaibot.git
pip install poetry
cd Openaibot
poetry install --all-extras
cp .env.exp .env&&nano .env
apt install npm -y && npm install pm2 && pm2 start pm2.json
pm2 monit

```

重启程序使用 `pm2 restart pm2.json` 。

> 推荐使用 `poetry` 进行依赖管理，因为我们使用了 `pydantic^1.9.0`，为了防止出现版本冲突，我们使用了 `poetry` 进行依赖管理。

## 🍪 Slash Command

```shell
clear - 删除聊天记录
help - 显示文档
chat - 对话
task - 启用函数以对话
ask - 禁止函数以对话
tool - 列出所有函数
set_endpoint - 设置私有 key 和 endpoint
clear_endpoint - 清除私有 key 和 endpoint
auth - 授权一个函数
env - 函数环境变量
token - 绑定令牌
token_clear - 清除令牌绑定
func_ban - 禁用一个函数
func_unban - 解禁一个函数
bind - 绑定消息源
unbind - 解绑消息源
```

## 💻 如何开发插件？

插件开发文档请参考 `plugins` 目录下的示例插件和 [🧀 插件开发文档](https://llmkira.github.io/Docs/dev/basic)

## 🤝 We need your help!

This is a long term project and we started the development of the LLM APP very early!

We applied a plugin-like system and search online before GPT3 OpenaiApi was released(davinci-003)

After many iterations, we have worked hard to make this project more standardized, generic, and open.

We can't do it on our own at the moment:

- [ ] We need help with the documentation
- [ ] Web UI

Feel free to submit a Pull Request or discuss, we'd love to receive your contribution!

## 📜 告知

> 此项目与 Openai 官方无关，全称为 OpenAiBot，表示开放人工智能机器人，并不表示为 Openai 所属机器人。

> 如果您所在辖区禁止使用 Openai 服务，请勿使用此项目。

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fsudoskys%2FOpenaibot.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Fsudoskys%2FOpenaibot?ref=badge_small)
