Skip to content

Commit

Permalink
change chatgpt_tool_hub version to 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfishh committed Jan 16, 2024
1 parent 55e9064 commit 3dea831
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
28 changes: 23 additions & 5 deletions plugins/tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
使用说明(默认trigger_prefix为$):
```text
#help tool: 查看tool帮助信息,可查看已加载工具列表
$tool 工具名 命令: [pure模式]:根据给出的{命令}使用指定 一个 可用工具尽力为你得到结果。
$tool 命令: [多工具模式]:根据给出的{命令}使用 一些 可用工具尽力为你得到结果。
$tool 工具名 命令: pure模式根据给出的{命令}使用指定 一个 可用工具尽力为你得到结果。
$tool 命令: 多工具模式根据给出的{命令}使用 一些 可用工具尽力为你得到结果。
$tool reset: 重置工具。
```
### 本插件所有工具同步存放至专用仓库:[chatgpt-tool-hub](https://github.com/goldfishh/chatgpt-tool-hub)
Expand All @@ -15,7 +15,7 @@ $tool reset: 重置工具。
3. 替换visual-dl(更名为visual)实现,目前识别图片链接效果较好。
4. 修复了0.4版本大部分工具返回结果不可靠问题

新版本工具名共19个,不一一列举,相应工具需要环境参数见`tool.py`里的`_build_tool_kwargs`函数
新版本工具名共19个,不一一列举,相应工具需要的环境参数见`tool.py`里的`_build_tool_kwargs`函数

## 使用说明
使用该插件后将默认使用4个工具, 无需额外配置长期生效:
Expand All @@ -30,10 +30,13 @@ $tool reset: 重置工具。
#### 2.2 browser
###### 浏览器,功能与2.1类似,但能更好模拟,不会被识别为爬虫影响获取网站内容

> 注1:url-get默认配置、browser已能自动下载好依赖
> 注1:url-get默认配置、browser需额外配置,browser依赖google-chrome,你需要提前安装好
> 注2:(可通过`browser_use_summary``url_get_use_summary`开关)当检测到长文本时会进入summary tool总结长文本,tokens可能会大量消耗!
这是debian端安装google-chrome教程,其他系统请自行查找
> https://www.linuxjournal.com/content/how-can-you-install-google-browser-debian
### 3. terminal
###### 在你运行的电脑里执行shell命令,可以配合你想要chatgpt生成的代码使用,给予自然语言控制手段

Expand Down Expand Up @@ -111,6 +114,21 @@ $tool reset: 重置工具。

> 安装教程:https://docs.searxng.org/admin/installation.html
### 14. email *
###### 发送邮件

### 15. sms *
###### 发送短信

### 16. stt *
###### speak to text 语音识别

### 17. tts *
###### text to speak 文生语音

### 18. wechat *
###### 向好友、群组发送微信

---

###### 注1:带*工具需要获取api-key才能使用(在config.json内的kwargs添加项),部分工具需要外网支持
Expand All @@ -120,7 +138,7 @@ $tool reset: 重置工具。
###### 默认工具无需配置,其它工具需手动配置,以增加morning-news和bing-search两个工具为例:
```json
{
"tools": ["bing-search", "news", "你想要添加的其他工具"], // 填入你想用到的额外工具名,这里加入了工具"bing-search"和工具"news"(news工具会自动加载morning-news、finance-news等子工具)
"tools": ["bing-search", "morning-news", "你想要添加的其他工具"], // 填入你想用到的额外工具名,这里加入了工具"bing-search"和工具"morning-news"
"kwargs": {
"debug": true, // 当你遇到问题求助时,需要配置
"request_timeout": 120, // openai接口超时时间
Expand Down
13 changes: 7 additions & 6 deletions plugins/tool/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ def __init__(self):
super().__init__()
self.handlers[Event.ON_HANDLE_CONTEXT] = self.on_handle_context

self.tool_config = self._read_json()
self.app_kwargs = self._build_tool_kwargs(self.tool_config.get("kwargs", {}))
self.app = self._reset_app()

logger.info("[tool] inited")
Expand All @@ -35,10 +33,12 @@ def get_help_text(self, verbose=False, **kwargs):
if not verbose:
return help_text
help_text += "\n使用说明:\n"
help_text += f"{trigger_prefix}tool " + "命令: 根据给出的{命令}使用一些可用工具尽力为你得到结果。\n"
help_text += f"{trigger_prefix}tool " + "命令: 根据给出的{命令}模型来选择使用哪些工具尽力为你得到结果。\n"
help_text += f"{trigger_prefix}tool 工具名 " + "命令: 根据给出的{命令}使用指定工具尽力为你得到结果。\n"
help_text += f"{trigger_prefix}tool reset: 重置工具。\n\n"

help_text += f"已加载工具列表: \n"
for idx, tool in enumerate(self.app.get_tool_list()):
for idx, tool in enumerate(main_tool_register.get_registered_tool_names()):
if idx != 0:
help_text += ", "
help_text += f"{tool}"
Expand Down Expand Up @@ -79,8 +79,6 @@ def on_handle_context(self, e_context: EventContext):
elif len(content_list) > 1:
if content_list[1].strip() == "reset":
logger.debug("[tool]: reset config")
self.tool_config = self._read_json()
self.app_kwargs = self._build_tool_kwargs(self.tool_config.get("kwargs", {}))
self.app = self._reset_app()
reply.content = "重置工具成功"
e_context["reply"] = reply
Expand Down Expand Up @@ -237,6 +235,9 @@ def _filter_tool_list(self, tool_list: list):
return valid_list

def _reset_app(self) -> App:
self.tool_config = self._read_json()
self.app_kwargs = self._build_tool_kwargs(self.tool_config.get("kwargs", {}))

app = AppFactory()
app.init_env(**self.app_kwargs)
# filter not support tool
Expand Down
2 changes: 1 addition & 1 deletion requirements-optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ web.py
wechatpy

# chatgpt-tool-hub plugin
chatgpt_tool_hub==0.4.6
chatgpt_tool_hub==0.5.0

# xunfei spark
websocket-client==1.2.0
Expand Down

0 comments on commit 3dea831

Please sign in to comment.