Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Pack #363

Merged
merged 47 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
515b6f1
:sparkles: feat(docs): add self-looping and advantages of language model
sudoskys Nov 16, 2023
683316a
:bug: fix: update start commands in README files
sudoskys Nov 18, 2023
30f03a7
fix(schema):hint
sudoskys Nov 21, 2023
09f06a7
feat(docs):update
sudoskys Nov 21, 2023
9112908
feat(task_schema):为每个Task对象链配备系列ID,用于识别不同的Task的派系
sudoskys Nov 21, 2023
41fa3fe
feat(llm_task):add system prompt
sudoskys Nov 22, 2023
6d2b6c8
Wrap send message in ChainFunc class
sudoskys Nov 25, 2023
b2d47b1
:sparkles: feat(fuse): Update exception handling in plugin exception …
sudoskys Nov 25, 2023
bb169c5
:truck: chore: Update dependency manager to pdm in README.md
sudoskys Nov 25, 2023
a7fac83
:art: chore(pyproject.toml): update project dependencies and metadata
sudoskys Nov 25, 2023
f7f4078
feat(pm2): update start commands for llm_sender and llm_receiver
sudoskys Nov 25, 2023
2192b9b
feat(pm2): update start commands for llm_sender and llm_receiver
sudoskys Nov 25, 2023
989633d
:truck: chore(Dockerfile): Update Dockerfile with improved package in…
sudoskys Nov 25, 2023
441d0ba
:truck: chore(Dockerfile): Update Dockerfile with improved package in…
sudoskys Nov 25, 2023
3c12357
Wrap sending message in ChainFunc
sudoskys Nov 25, 2023
ab02bfb
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
194bdfc
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
62490c8
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
007ea2b
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
794a5b9
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
4ef9333
feat: Update dependencies in pyproject.toml
sudoskys Nov 25, 2023
2a7bd4f
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 25, 2023
022d0c6
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 25, 2023
6dc2b5b
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 25, 2023
d35d3d4
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 25, 2023
f94c116
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 25, 2023
15bf8f3
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 26, 2023
2d6be9c
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 26, 2023
83a5b67
:rocket: chore(pyproject.toml): update dependencies
sudoskys Nov 26, 2023
90332f0
Wrap sending message in ChainFunc's notify_user method
sudoskys Nov 26, 2023
fdc9613
:building_construction: chore: Update Python version in Dockerfile
sudoskys Nov 26, 2023
9c93ed5
:building_construction: chore: Update Python version in Dockerfile
sudoskys Nov 26, 2023
78b4bb7
:bug: fix: Update dependencies for compatibility with hikari 2.0.0.de…
sudoskys Nov 26, 2023
a351d1d
:bug: fix: Update dependencies for compatibility with hikari 2.0.0.de…
sudoskys Nov 26, 2023
45d17fb
feat: Add 'Level High' label for bugfixes and 'Broken Change' label f…
sudoskys Nov 26, 2023
097c9f6
:hammer: chore: fix line formatting in function.py and receiver_clien…
sudoskys Nov 29, 2023
ff8735f
✨ feat: Update llmkira/task/schema.py
sudoskys Dec 3, 2023
f3f6f90
feat: Add pre-commit hooks for code quality checks
sudoskys Dec 11, 2023
55c7c29
feat(pm2.json):add
sudoskys Dec 15, 2023
ce2b7f4
feat(pm2.json):add
sudoskys Dec 23, 2023
ad0c2fb
feat(pm2.json):add
sudoskys Jan 14, 2024
0140839
feat(pm2.json):fix
sudoskys Jan 17, 2024
b0f1789
feat(pm2.json):ChainBat
sudoskys Jan 17, 2024
bbbf90e
feat(pm2.json):ChainBat
sudoskys Jan 17, 2024
a58a322
feat(pm2.json):ChainBat
sudoskys Jan 17, 2024
ade5cc7
feat(pm2.json):ChainBat
sudoskys Jan 17, 2024
02cc230
feat(pm2.json):ChainBat
sudoskys Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env.exp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ OPENAI_API_ENDPOINT=https://api.openai.com/v1/chat/completions
# OPENAI_API_ORG_ID=org-xxx
# OPENAI_API_PROXY=socks5://127.0.0.1:7890


AMQP_DSN=amqp://admin:8a8a8a@localhost:5672/
REDIS_DSN=redis://localhost:6379/0
MONGODB_DSN=mongodb://admin:8a8a8a@localhost:27017/?authSource=admin
# SENTRY_DSN=xxxx


SERVICE_PROVIDER=public


# TELEGRAM_BOT_TOKEN=xxx
# TELEGRAM_BOT_PROXY_ADDRESS=socks5://127.0.0.1:7890

Expand All @@ -30,5 +27,4 @@ SERVICE_PROVIDER=public
# SLACK_SIGNING_SECRET=xxxxxxxxxxxxx
# SLACK_BOT_PROXY_ADDRESS=http://


# LLMBOT_LOG_OUTPUT=DEBUG
3 changes: 3 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ categories:
labels:
- 'fix'
- 'bugfix'
- 'Level High'
- 'Bug'
- 'Bugfix'
- title: '🧰 Maintenance'
labels:
- 'Broken Change'
- 'PluginApi'
- 'Slow progress'
- 'Improve our documentation'
- title: '🎮 New Plugin'
labels:
Expand Down
29 changes: 12 additions & 17 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,23 @@ on:
- '**-develop'

jobs:
test:

runs-on: ubuntu-latest
Testing:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ 3.8.x, 3.9.x,3.10.x ,3.11.x ]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
os: [ ubuntu-latest ] # , windows-latest, macos-latest ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v3
- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"

- name: Install dependencies
run: |
pip install poetry==1.6.1
poetry install --all-extras
python -m pip install pytest

- name: Run tests
pdm install --no-lock -G testing
- name: Run Tests
run: |
poetry install --all-extras
cd test
poetry run pytest
pdm run -v pytest tests
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
42 changes: 16 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
# 第一个阶段
FROM python:3.11-buster as builder
FROM python:3.9-buster as builder

RUN apt update && apt install -y build-essential \
&& pip install poetry==1.6.1
RUN apt update && \
apt install -y build-essential && \
pip install -U pip setuptools wheel && \
pip install pdm

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

WORKDIR /app

COPY ["pyproject.toml", "poetry.lock", "/app/"]

VOLUME ["/redis", "/rabbitmq", "/mongodb", "run.log", "/config_dir"]

RUN poetry config virtualenvs.in-project true && \
poetry install --all-extras --no-root && rm -rf $POETRY_CACHE_DIR
COPY pyproject.toml pdm.lock README.md /project/
WORKDIR /project
RUN pdm sync -G bot --prod --no-editable

# 第二个阶段
FROM python:3.11-slim-buster as runtime
FROM python:3.9-slim-buster as runtime

RUN apt update && \
apt install -y npm && \
RUN apt update && \
apt install -y npm && \
npm install pm2 -g && \
pip install poetry==1.6.1 && \
apt install ffmpeg -y
apt install -y ffmpeg && \
pip install pdm

ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
VOLUME ["/redis", "/rabbitmq", "/mongodb", "/run.log", "/config_dir"]

WORKDIR /app

COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /project/.venv /app/.venv

COPY pm2.json ./
COPY config_dir ./config_dir
COPY . /app

CMD [ "pm2-runtime", "pm2.json" ]
CMD [ "pm2-runtime", "pm2.json" ]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ documentation [here](https://llmkira.github.io/Docs/en).**

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

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

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

Expand Down Expand Up @@ -151,18 +151,18 @@ docker-compose -f docker-compose.yml up -d

```shell
git clone https://github.com/LlmKira/Openaibot.git
pip install poetry
pip install pdm
cd Openaibot
poetry install --all-extras
cp .env.exp .env&&nano .env
pdm install -G bot
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` 进行依赖管理。
> 推荐使用 `pdm` 进行依赖管理,因为我们使用了 `pydantic^1.9.0`,为了防止出现版本冲突,我们使用了 `pdm` 进行依赖管理。

## 🍪 Slash Command

Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Both the authentication component and the backend need to be implemented by your

Read the [🧀 Deployment Documentation](https://llmkira.github.io/Docs/) for more information.

Please use `python3 start_sender.py` `python3 start_receiver.py` to test whether it can run normally.
Please use `poetry run python3 start_sender.py` `poetry run python3 start_receiver.py` to test whether it can run normally.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command instructions for running the application have been updated to use poetry, but it's important to ensure that the poetry dependency management tool is mentioned in the prerequisites or installation instructions within the README. If it's not already included, users may encounter issues when trying to run the commands without having poetry installed.


#### Performance indicator test (Until 2023/11/1)

Expand Down
4 changes: 2 additions & 2 deletions docs/SeriveProvider.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,76 @@ AGI:情绪不拟人,反而要用人的方式操作物理GUI。

审查:语言模型最大的优势本来就是情绪价值。

## 自我回流

## 语言模型的优势

## 应用性

## 释放链是否需要强匹配

## 评估 Openai 的 Assistant 的实现

https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps

这个实现很像Github的CI/CD。

我们采用的是简单的 Meta + 简单队列的方式。

不足之处:我们混合了无数线程,导致预料外的排序预期。

```python

run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
model="gpt-4-1106-preview",
instructions="additional instructions",
tools=[{"type": "code_interpreter"}, {"type": "retrieval"}]
)
```

这实际上是一个 `Batch` 的实现。这种私有实现我是应该不会接入的。因为和我们整个系统都冲突了。

不过仍有参考价值。我们需要调整schema,增加线程设计。更加规范化 “子链递送”,排查所有的 TaskHeader 子类产生。

`instructions` 这个字段,和我们插件的管理器 Access 是相对应的。

### GPTs

网页的设计本身就是一个限制。虽然他们的设计很好,但是实用性集成性不足。

既然要 Function 了... 仍然像小程序一样工作,可能并不会很好。而且这个设计本身就有账户权限的准入门槛。

现在受欢迎的都是 集成,copilot,小爱,这些都是和生产环境集成的。

### 核心方向

- 查询构建解决方案
- 格式化工作流输入

没有实业的参与,不会提升生产力。

从企业构建上说,客服组件,工单系统的NLP替换,这些都是很好的方向。

传统的订单下单模式,甚至也可能被替换为交互式的。

除了 inspecter 大概能做,其他都不太行。

本框架的核心方向是,**构建一个可配置组件的协作平台**。

那么基于 Bots 的话,有些地方还是不合格的,比如,命令自定义,这个就没有自定义 hook 的选项。

订单 shcema -> 信息索引 + 交互提取 -> 确认。

其中前两步写一点包装其实就可以用了。要想清楚框架的存在意义。

## 平台指定支持

插件需要支持平台指定,这个是一个很重要的功能。

## 通道

通道是一个很重要的概念.

我们依赖这个来充当事件的调度器。让链可随时启动。
16 changes: 5 additions & 11 deletions llmkira/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# @Author : sudoskys
# @File : error.py
# @Software: PyCharm
# 更安全的 format
import random


class ReplyNeededError(Exception):
Expand All @@ -15,10 +17,6 @@ def __init__(self, message: str = None, *args):
super().__init__(message, *args)


# 更安全的 format
import random


class MappingDefault(dict):
def __missing__(self, key):
return key
Expand Down Expand Up @@ -61,9 +59,7 @@ def __missing__(self, key):

def get_request_error_message(error: str):
_txt: str = random.choice(REQUEST_ERROR_MESSAGE_TEMPLATE)
return _txt.format_map(
MappingDefault(error=error)
)
return _txt.format_map(MappingDefault(error=error))


# 同样贴心的上传错误提示 (ノ>ω<)ノ
Expand All @@ -78,12 +74,10 @@ def get_request_error_message(error: str):
"OMG, {filename} ,ERROR UPLOAD, `{error}`",
"WTF, I CANT UPLOAD {filename} BECAUSE `{error}`",
"MY PHONE IS BROKEN, I CANT UPLOAD {filename} BECAUSE `{error}`",
"As a human, I can't upload {filename} for you :( \n `{error}`"
"As a human, I can't upload {filename} for you :( \n `{error}`",
]


def get_upload_error_message(filename: str, error: str):
_txt: str = random.choice(REQUEST_ERROR_MESSAGE_TEMPLATE)
return _txt.format_map(
MappingDefault(filename=filename, error=error)
)
return _txt.format_map(MappingDefault(filename=filename, error=error))
Loading
Loading