Skip to content

Commit

Permalink
Review code for the linkai plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
江纬 committed Nov 5, 2023
1 parent 3552cf1 commit 3745e00
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '2.0'
services:
chatgpt-on-wechat:
image: zhayujie/chatgpt-on-wechat
container_name: chatgpt-on-wechat
security_opt:
- seccomp:unconfined
environment:
OPEN_AI_API_KEY: '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'
MODEL: 'gpt-3.5-turbo'
PROXY: ''
SINGLE_CHAT_PREFIX: '["bot", "@bot"]'
SINGLE_CHAT_REPLY_PREFIX: '"[bot] "'
GROUP_CHAT_PREFIX: '["@bot"]'
GROUP_NAME_WHITE_LIST: '["ChatGPT测试群", "ChatGPT测试群2", "AI原优舍运营"]'
IMAGE_CREATE_PREFIX: '["画", "看", "找"]'
CONVERSATION_MAX_TOKENS: 1000
SPEECH_RECOGNITION: 'False'
CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
EXPIRES_IN_SECONDS: 3600
USE_GLOBAL_PLUGIN_CONFIG: 'True'
USE_LINKAI: 'False'
LINKAI_API_KEY: ''
LINKAI_APP_CODE: ''
2 changes: 1 addition & 1 deletion plugins/bdunit/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 插件说明

利用百度UNIT实现智能对话
会在后续版本中去掉,利用百度UNIT实现智能对话

- 1.解决问题:chatgpt无法处理的指令,交给百度UNIT处理如:天气,日期时间,数学运算等
- 2.如问时间:现在几点钟,今天几号
Expand Down
4 changes: 2 additions & 2 deletions plugins/finish/finish.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
desire_priority=-999,
hidden=True,
desc="A plugin that check unknown command",
version="1.0",
author="js00000",
version="1.0.1",
author="algmon",
)
class Finish(Plugin):
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/godcmd/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 插件说明

指令插件
管理员(即上帝)模式

## 插件使用

Expand All @@ -9,7 +9,7 @@
如果没有设置命令,在命令行日志中会打印出本次的临时口令,请注意观察,打印格式如下。

```
[INFO][2023-04-06 23:53:47][godcmd.py:165] - [Godcmd] 因未设置口令,本次的临时口令为0971。
[INFO][2023-11-05 22:44:44][godcmd.py:165] - [Godcmd] 因未设置口令,本次的临时口令为0971。
```

在私聊中可使用`#auth`指令,输入口令进行管理员认证。更多详细指令请输入`#help`查看帮助文档:
Expand Down
5 changes: 2 additions & 3 deletions plugins/godcmd/godcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def get_help_text(isadmin, isgroup):
desire_priority=999,
hidden=True,
desc="为你的机器人添加指令集,有用户和管理员两种角色,加载顺序请放在首位,初次运行后插件目录会生成配置文件, 填充管理员密码后即可认证",
version="1.0",
author="lanvent",
version="1.0.1",
author="algmon",
)
class Godcmd(Plugin):
def __init__(self):
Expand Down Expand Up @@ -461,7 +461,6 @@ def authenticate(self, userid, args, isadmin, isgroup) -> Tuple[bool, str]:
def get_help_text(self, isadmin=False, isgroup=False, **kwargs):
return get_help_text(isadmin, isgroup)


def is_admin_in_group(self, context):
if context["isgroup"]:
return context.kwargs.get("msg").actual_user_id in global_config["admin_users"]
Expand Down
6 changes: 3 additions & 3 deletions plugins/hello/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
name="Hello",
desire_priority=-1,
hidden=True,
desc="A simple plugin that says hello",
version="0.1",
author="lanvent",
desc="A simple plugin that says hello to new user in the group",
version="0.1.1",
author="algmon",
)
class Hello(Plugin):
def __init__(self):
Expand Down
14 changes: 8 additions & 6 deletions plugins/linkai/linkai.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import os
from .utils import Util


@plugins.register(
name="linkai",
desc="A plugin that supports knowledge base and midjourney drawing.",
version="0.1.0",
author="https://link-ai.tech",
desc="A plugin that supports knowledge base, midjourney drawing and summary.",
version="0.1.1",
author="algmon",
desire_priority=99
)
class LinkAI(Plugin):
Expand All @@ -32,7 +33,6 @@ def __init__(self):
self.sum_config = self.config.get("summary")
logger.info(f"[LinkAI] inited, config={self.config}")


def on_handle_context(self, e_context: EventContext):
"""
消息处理逻辑
Expand Down Expand Up @@ -112,12 +112,10 @@ def on_handle_context(self, e_context: EventContext):
e_context.action = EventAction.BREAK_PASS
return


if self._is_chat_task(e_context):
# 文本对话任务处理
self._process_chat_task(e_context)


# 插件管理功能
def _process_admin_cmd(self, e_context: EventContext):
context = e_context['context']
Expand Down Expand Up @@ -265,15 +263,19 @@ def _set_reply_text(content: str, e_context: EventContext, level: ReplyType = Re
e_context["reply"] = reply
e_context.action = EventAction.BREAK_PASS


def _get_trigger_prefix():
return conf().get("plugin_trigger_prefix", "$")


def _find_sum_id(context):
return USER_FILE_MAP.get(_find_user_id(context) + "-sum_id")


def _find_file_id(context):
user_id = _find_user_id(context)
if user_id:
return USER_FILE_MAP.get(user_id + "-file_id")


USER_FILE_MAP = ExpiredDict(conf().get("expires_in_seconds") or 60 * 30)

0 comments on commit 3745e00

Please sign in to comment.