From 4824905592d608e133eb9e4962c803ace0a369b0 Mon Sep 17 00:00:00 2001
From: Yao Xiao
Date: Tue, 7 Nov 2023 09:48:01 +0800
Subject: [PATCH 01/24] Add new API support
---
config.py | 2 +-
request_llm/bridge_all.py | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/config.py b/config.py
index b4f00a63..903ee20f 100644
--- a/config.py
+++ b/config.py
@@ -87,7 +87,7 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview","gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
"api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
"gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
"chatglm", "moss", "newbing", "claude-2"]
diff --git a/request_llm/bridge_all.py b/request_llm/bridge_all.py
index f85d1b6b..3d6e4bd7 100644
--- a/request_llm/bridge_all.py
+++ b/request_llm/bridge_all.py
@@ -117,6 +117,15 @@ model_info = {
"token_cnt": get_token_num_gpt35,
},
+ "gpt-3.5-turbo-1106": {#16k
+ "fn_with_ui": chatgpt_ui,
+ "fn_without_ui": chatgpt_noui,
+ "endpoint": openai_endpoint,
+ "max_token": 16385,
+ "tokenizer": tokenizer_gpt35,
+ "token_cnt": get_token_num_gpt35,
+ },
+
"gpt-4": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
@@ -135,6 +144,15 @@ model_info = {
"token_cnt": get_token_num_gpt4,
},
+ "gpt-4-1106-preview": {
+ "fn_with_ui": chatgpt_ui,
+ "fn_without_ui": chatgpt_noui,
+ "endpoint": openai_endpoint,
+ "max_token": 128000,
+ "tokenizer": tokenizer_gpt4,
+ "token_cnt": get_token_num_gpt4,
+ },
+
"gpt-3.5-random": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
From 136e6aaa21102cc41ca87afa62be8ee510e07c41 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:08:24 +0800
Subject: [PATCH 02/24] Update config.py
---
config.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.py b/config.py
index b4f00a63..b74f1e66 100644
--- a/config.py
+++ b/config.py
@@ -87,9 +87,9 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5",
"api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
- "gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
+ "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4",
"chatglm", "moss", "newbing", "claude-2"]
# P.S. 其他可用的模型还包括 ["qianfan", "llama2", "qwen", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613", "gpt-3.5-random"
# "spark", "sparkv2", "sparkv3", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"]
From 0897057be1ab8ebdf3ffad9b3d4c50add68b6aa5 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:11:52 +0800
Subject: [PATCH 03/24] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 0378eaa1..eeb354a7 100644
--- a/README.md
+++ b/README.md
@@ -139,7 +139,7 @@ git clone --depth=1 https://github.com/OpenLMLab/MOSS.git request_llm/moss #
参考wiki:https://github.com/binary-husky/gpt_academic/wiki/%E9%80%82%E9%85%8DRWKV-Runner
# 【可选步骤IV】确保config.py配置文件的AVAIL_LLM_MODELS包含了期望的模型,目前支持的全部模型如下(jittorllms系列目前仅支持docker方案):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
From 4d9256296d2ae17e49d523ce4dc557104c35ce1c Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:13:37 +0800
Subject: [PATCH 04/24] =?UTF-8?q?Update=20=E5=A4=9A=E6=99=BA=E8=83=BD?=
=?UTF-8?q?=E4=BD=93.py?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/多智能体.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crazy_functions/多智能体.py b/crazy_functions/多智能体.py
index 5a4c4a58..a2d0ce74 100644
--- a/crazy_functions/多智能体.py
+++ b/crazy_functions/多智能体.py
@@ -32,7 +32,7 @@ def 多智能体终端(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_
web_port 当前软件运行的端口号
"""
# 检查当前的模型是否符合要求
- supported_llms = ['gpt-3.5-turbo-16k', 'gpt-4', 'gpt-4-32k',
+ supported_llms = ['gpt-3.5-turbo-16k', 'gpt-3.5-turbo-1106', 'gpt-4', 'gpt-4-32k', 'gpt-4-1106-preview',
'api2d-gpt-3.5-turbo-16k', 'api2d-gpt-4']
llm_kwargs['api_key'] = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
if llm_kwargs['llm_model'] not in supported_llms:
From 3ed0e8012d86be9f37d11be8db5dc2a1dfb1db51 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:17:01 +0800
Subject: [PATCH 05/24] Update bridge_all.py
---
request_llm/bridge_all.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/request_llm/bridge_all.py b/request_llm/bridge_all.py
index f85d1b6b..2c535378 100644
--- a/request_llm/bridge_all.py
+++ b/request_llm/bridge_all.py
@@ -108,6 +108,15 @@ model_info = {
"token_cnt": get_token_num_gpt35,
},
+ "gpt-3.5-turbo-1106": {
+ "fn_with_ui": chatgpt_ui,
+ "fn_without_ui": chatgpt_noui,
+ "endpoint": openai_endpoint,
+ "max_token": 1024 *16,
+ "tokenizer": tokenizer_gpt35,
+ "token_cnt": get_token_num_gpt35,
+ },
+
"gpt-3.5-turbo-16k-0613": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
@@ -135,6 +144,15 @@ model_info = {
"token_cnt": get_token_num_gpt4,
},
+ "gpt-4-1106-preview": {
+ "fn_with_ui": chatgpt_ui,
+ "fn_without_ui": chatgpt_noui,
+ "endpoint": openai_endpoint,
+ "max_token": 1024 * 128,
+ "tokenizer": tokenizer_gpt4,
+ "token_cnt": get_token_num_gpt4,
+ },
+
"gpt-3.5-random": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
From 61cf2b32eb979607b41f1240f478f70d9d447b5a Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:21:08 +0800
Subject: [PATCH 06/24] Update README.md.German.md
---
docs/README.md.German.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/README.md.German.md b/docs/README.md.German.md
index d514de30..fa15a8a7 100644
--- a/docs/README.md.German.md
+++ b/docs/README.md.German.md
@@ -111,7 +111,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # When executing this line of code, you must be in the project root path
# [Optional Step III] Make sure the AVAIL_LLM_MODELS in the config.py configuration file contains the expected models. Currently supported models are as follows (jittorllms series currently only supports docker solutions):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
@@ -304,4 +304,4 @@ https://github.com/kaixindelele/ChatPaper
# Mehr:
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
-```
\ No newline at end of file
+```
From bba3419ace4031bb8a29695a53ffe0ea54abac98 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:21:32 +0800
Subject: [PATCH 07/24] Update README.md.Italian.md
---
docs/README.md.Italian.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/README.md.Italian.md b/docs/README.md.Italian.md
index 76efe185..fc01a27e 100644
--- a/docs/README.md.Italian.md
+++ b/docs/README.md.Italian.md
@@ -117,7 +117,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # Si prega di notare che quando si esegue questa riga di codice, si deve essere nella directory radice del progetto
# 【Passaggio facoltativo III】 Assicurati che il file di configurazione config.py includa tutti i modelli desiderati, al momento tutti i modelli supportati sono i seguenti (i modelli della serie jittorllms attualmente supportano solo la soluzione docker):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
From 6c3405ba550c9e846643ce78b51675310ecfbb2a Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:21:52 +0800
Subject: [PATCH 08/24] Update README.md.Korean.md
---
docs/README.md.Korean.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/README.md.Korean.md b/docs/README.md.Korean.md
index 61b8e4a0..7bdcb8b9 100644
--- a/docs/README.md.Korean.md
+++ b/docs/README.md.Korean.md
@@ -112,7 +112,7 @@ git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # 다음 코
# [선택 사항III] AVAIL_LLM_MODELS config.py 구성 파일에 기대하는 모델이 포함되어 있는지 확인하십시오.
# 현재 지원되는 전체 모델 :
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
From cd40bf9ae2e9dd047aebc42ab4e40a6ba95bb219 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:22:12 +0800
Subject: [PATCH 09/24] Update README.md.Portuguese.md
---
docs/README.md.Portuguese.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/README.md.Portuguese.md b/docs/README.md.Portuguese.md
index 2347d5a7..6c368f75 100644
--- a/docs/README.md.Portuguese.md
+++ b/docs/README.md.Portuguese.md
@@ -127,7 +127,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # Note: When executing this line of code, you must be in the project root path
# 【Optional Step III】Make sure that the AVAIL_LLM_MODELS in the config.py configuration file contains the expected model. Currently, all supported models are as follows (jittorllms series currently only supports docker solutions):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
From 77220002e0faad0627f09fa40320c9c70a68269a Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:22:29 +0800
Subject: [PATCH 10/24] Update README_EN.md
---
docs/README_EN.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/README_EN.md b/docs/README_EN.md
index 02b8588c..1a68810a 100644
--- a/docs/README_EN.md
+++ b/docs/README_EN.md
@@ -114,7 +114,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # When executing this line of code, you must be in the root directory of the project
# [Optional Step III] Make sure the AVAIL_LLM_MODELS in the config.py configuration file includes the expected models. Currently supported models are as follows (the jittorllms series only supports the docker solution for the time being):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
@@ -319,4 +319,4 @@ https://github.com/kaixindelele/ChatPaper
# More:
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
-```
\ No newline at end of file
+```
From 3141cd392a881edf37644acbd61b87d728fc1a16 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:22:46 +0800
Subject: [PATCH 11/24] Update README_FR.md
---
docs/README_FR.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/README_FR.md b/docs/README_FR.md
index af3bb42c..4df3c840 100644
--- a/docs/README_FR.md
+++ b/docs/README_FR.md
@@ -119,7 +119,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # Note: When running this line of code, you must be in the project root path.
# 【Optional Step III】Make sure the AVAIL_LLM_MODELS in the config.py configuration file contains the desired model. Currently, all models supported are as follows (the jittorllms series currently only supports the docker scheme):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
@@ -320,4 +320,4 @@ https://github.com/kaixindelele/ChatPaper
# Plus :
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
-```
\ No newline at end of file
+```
From 6c795809f76826fda9da5630133d816c46dee856 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:23:01 +0800
Subject: [PATCH 12/24] Update README_JP.md
---
docs/README_JP.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/README_JP.md b/docs/README_JP.md
index 46145e1f..3b03545a 100644
--- a/docs/README_JP.md
+++ b/docs/README_JP.md
@@ -128,7 +128,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # Note that when executing this line of code, it must be in the project root.
# 【Optional Step III】Ensure that the AVAIL_LLM_MODELS in the config.py configuration file contains the expected model. Currently, all supported models are as follows (jittorllms series currently only supports the docker solution):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
@@ -326,4 +326,4 @@ https://github.com/kaixindelele/ChatPaper
# その他:
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
-```
\ No newline at end of file
+```
From 3a2466fe4ea6281f24affdccf22d3321b7ec7d52 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:23:16 +0800
Subject: [PATCH 13/24] Update README_RS.md
---
docs/README_RS.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/README_RS.md b/docs/README_RS.md
index d4888a05..e050d442 100644
--- a/docs/README_RS.md
+++ b/docs/README_RS.md
@@ -116,7 +116,7 @@ python -m pip install -r request_llm/requirements_moss.txt
git clone https://github.com/OpenLMLab/MOSS.git request_llm/moss # Note that when executing this line of code, you must be in the project root path
# [Optional step III] Make sure the AVAIL_LLM_MODELS in the config.py configuration file contains the expected models. Currently, all supported models are as follows (the jittorllms series currently only supports the docker solution):
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing", "moss"] # + ["jittorllms_rwkv", "jittorllms_pangualpha", "jittorllms_llama"]
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "azure-gpt-3.5", "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k', "gpt-4", "gpt-4-32k", "gpt-4-1106-preview", "azure-gpt-4", "api2d-gpt-4", "chatglm", "moss", "newbing", "claude-2"]
```
@@ -275,4 +275,4 @@ https://github.com/kaixindelele/ChatPaper
# Больше:
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
-```
\ No newline at end of file
+```
From ffe6c1403e2d7f4a07434da3af07de5f21134973 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 14:25:36 +0800
Subject: [PATCH 14/24] Update bridge_chatgpt.py
---
request_llm/bridge_chatgpt.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/request_llm/bridge_chatgpt.py b/request_llm/bridge_chatgpt.py
index 9903da9d..292de0ad 100644
--- a/request_llm/bridge_chatgpt.py
+++ b/request_llm/bridge_chatgpt.py
@@ -351,6 +351,7 @@ def generate_payload(inputs, llm_kwargs, history, system_prompt, stream):
model = random.choice([
"gpt-3.5-turbo",
"gpt-3.5-turbo-16k",
+ "gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0613",
"gpt-3.5-turbo-16k-0613",
"gpt-3.5-turbo-0301",
From 736f1214ee156a80c461cf011156f973bbd6cb56 Mon Sep 17 00:00:00 2001
From: Skyzayre <120616113+Skyzayre@users.noreply.github.com>
Date: Tue, 7 Nov 2023 15:55:23 +0800
Subject: [PATCH 15/24] Update bridge_all.py
---
request_llm/bridge_all.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/request_llm/bridge_all.py b/request_llm/bridge_all.py
index 2c535378..a1dd7f6c 100644
--- a/request_llm/bridge_all.py
+++ b/request_llm/bridge_all.py
@@ -112,7 +112,7 @@ model_info = {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": openai_endpoint,
- "max_token": 1024 *16,
+ "max_token": 16385,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
@@ -148,7 +148,7 @@ model_info = {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": openai_endpoint,
- "max_token": 1024 * 128,
+ "max_token": 128000,
"tokenizer": tokenizer_gpt4,
"token_cnt": get_token_num_gpt4,
},
From 8d94564e675ac492068ffb9884a2df217bf7bf37 Mon Sep 17 00:00:00 2001
From: awwaawwa <8493196+awwaawwa@users.noreply.github.com>
Date: Tue, 7 Nov 2023 15:59:07 +0800
Subject: [PATCH 16/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20gpt-3.5-turbo-16k=20?=
=?UTF-8?q?=E7=B3=BB=E5=88=97=E6=A8=A1=E5=9E=8B=20max=5Ftoken=20=E4=B8=BA?=
=?UTF-8?q?=2016385?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
根据 https://platform.openai.com/docs/models/gpt-3-5 ,这个16k的3.5上下文窗口其实是16385
---
request_llms/bridge_all.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py
index 27b91c26..69a99e9b 100644
--- a/request_llms/bridge_all.py
+++ b/request_llms/bridge_all.py
@@ -94,7 +94,7 @@ model_info = {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": openai_endpoint,
- "max_token": 1024*16,
+ "max_token": 16385,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
@@ -112,7 +112,7 @@ model_info = {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": openai_endpoint,
- "max_token": 1024 * 16,
+ "max_token": 16385,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
@@ -186,7 +186,7 @@ model_info = {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
"endpoint": api2d_endpoint,
- "max_token": 1024*16,
+ "max_token": 16385,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
From 0ff750b60a645c739ab09173a86d0ab9b1482483 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 12:40:25 +0800
Subject: [PATCH 17/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=A9=E8=BF=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config.py | 3 ++-
request_llms/bridge_all.py | 12 ++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/config.py b/config.py
index f44c47dd..38d05198 100644
--- a/config.py
+++ b/config.py
@@ -87,7 +87,8 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
# 模型选择是 (注意: LLM_MODEL是默认选中的模型, 它*必须*被包含在AVAIL_LLM_MODELS列表中 )
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
-AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview","gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
+AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview",
+ "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
"api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
"gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
"chatglm3", "moss", "newbing", "claude-2"]
diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py
index 6d34d951..3a93234e 100644
--- a/request_llms/bridge_all.py
+++ b/request_llms/bridge_all.py
@@ -145,12 +145,12 @@ model_info = {
},
"gpt-4-1106-preview": {
- "fn_with_ui": chatgpt_ui,
- "fn_without_ui": chatgpt_noui,
- "endpoint": openai_endpoint,
- "max_token": 128000,
- "tokenizer": tokenizer_gpt4,
- "token_cnt": get_token_num_gpt4,
+ "fn_with_ui": chatgpt_ui,
+ "fn_without_ui": chatgpt_noui,
+ "endpoint": openai_endpoint,
+ "max_token": 128000,
+ "tokenizer": tokenizer_gpt4,
+ "token_cnt": get_token_num_gpt4,
},
"gpt-3.5-random": {
From a1a91c25a5ac2e3928e7dd17b21f70e7694cfca6 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 12:53:03 +0800
Subject: [PATCH 18/24] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?=
=?UTF-8?q?=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
request_llms/bridge_all.py | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py
index cb71843e..3a93234e 100644
--- a/request_llms/bridge_all.py
+++ b/request_llms/bridge_all.py
@@ -108,15 +108,6 @@ model_info = {
"token_cnt": get_token_num_gpt35,
},
- "gpt-3.5-turbo-1106": {
- "fn_with_ui": chatgpt_ui,
- "fn_without_ui": chatgpt_noui,
- "endpoint": openai_endpoint,
- "max_token": 16385,
- "tokenizer": tokenizer_gpt35,
- "token_cnt": get_token_num_gpt35,
- },
-
"gpt-3.5-turbo-16k-0613": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
From 33bf795c663587ec86d5a852a14a7560b1af09a5 Mon Sep 17 00:00:00 2001
From: xiangsam
Date: Fri, 10 Nov 2023 11:45:47 +0000
Subject: [PATCH 19/24] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=B2=BE=E5=87=86?=
=?UTF-8?q?=E7=BF=BB=E8=AF=91PDF=E6=96=87=E6=A1=A3(NOUGAT)=E6=8F=92?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/crazy_utils.py | 2 +-
crazy_functions/批量翻译PDF文档_NOUGAT.py | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/crazy_functions/crazy_utils.py b/crazy_functions/crazy_utils.py
index a23c732b..ce7a2e39 100644
--- a/crazy_functions/crazy_utils.py
+++ b/crazy_functions/crazy_utils.py
@@ -748,7 +748,7 @@ class nougat_interface():
yield from update_ui_lastest_msg("正在解析论文, 请稍候。进度:正在加载NOUGAT... (提示:首次运行需要花费较长时间下载NOUGAT参数)",
chatbot=chatbot, history=history, delay=0)
- self.nougat_with_timeout(f'nougat --out "{os.path.abspath(dst)}" "{os.path.abspath(fp)}"', os.getcwd(), timeout=3600)
+ self.nougat_with_timeout(f'nougat --out "{os.path.abspath(dst)}" "{os.path.abspath(fp)}" --recompute --no-skipping --markdown --batchsize 8', os.getcwd(), timeout=3600)
res = glob.glob(os.path.join(dst,'*.mmd'))
if len(res) == 0:
self.threadLock.release()
diff --git a/crazy_functions/批量翻译PDF文档_NOUGAT.py b/crazy_functions/批量翻译PDF文档_NOUGAT.py
index 3e50c93a..50e34c4e 100644
--- a/crazy_functions/批量翻译PDF文档_NOUGAT.py
+++ b/crazy_functions/批量翻译PDF文档_NOUGAT.py
@@ -73,6 +73,11 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
from .crazy_utils import get_files_from_everything
success, file_manifest, project_folder = get_files_from_everything(txt, type='.pdf')
+ success_mmd, file_manifest_mmd, _ = get_files_from_everything(txt, type='.mmd')
+ success = success or success_mmd
+ file_manifest += file_manifest_mmd
+ chatbot.append(["文件列表:", ", ".join([e.split('/')[-1] for e in file_manifest])]);
+ yield from update_ui( chatbot=chatbot, history=history)
# 检测输入参数,如没有给定输入参数,直接退出
if not success:
if txt == "": txt = '空空如也的输入栏'
@@ -101,9 +106,13 @@ def 解析PDF_基于NOUGAT(file_manifest, project_folder, llm_kwargs, plugin_kwa
from crazy_functions.pdf_fns.report_gen_html import construct_html
nougat_handle = nougat_interface()
for index, fp in enumerate(file_manifest):
- chatbot.append(["当前进度:", f"正在解析论文,请稍候。(第一次运行时,需要花费较长时间下载NOUGAT参数)"]); yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
- fpp = yield from nougat_handle.NOUGAT_parse_pdf(fp, chatbot, history)
- promote_file_to_downloadzone(fpp, rename_file=os.path.basename(fpp)+'.nougat.mmd', chatbot=chatbot)
+ if fp.endswith('pdf'):
+ chatbot.append(["当前进度:", f"正在解析论文,请稍候。(第一次运行时,需要花费较长时间下载NOUGAT参数)"]); yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
+ fpp = yield from nougat_handle.NOUGAT_parse_pdf(fp, chatbot, history)
+ promote_file_to_downloadzone(fpp, rename_file=os.path.basename(fpp)+'.nougat.mmd', chatbot=chatbot)
+ else:
+ chatbot.append(["当前论文无需解析:", fp]); yield from update_ui( chatbot=chatbot, history=history)
+ fpp = fp
with open(fpp, 'r', encoding='utf8') as f:
article_content = f.readlines()
article_dict = markdown_to_dict(article_content)
From 0299b0f95f6c264ca4dbf8809fb1e09c00702ec4 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 20:59:08 +0800
Subject: [PATCH 20/24] =?UTF-8?q?=E6=94=AF=E6=8C=81DALLE3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functional.py | 17 +++++++++++---
crazy_functions/图片生成.py | 31 ++++++++++++++++++++++++--
docs/translate_english.json | 2 +-
docs/translate_japanese.json | 2 +-
docs/translate_traditionalchinese.json | 2 +-
5 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index 2d7fa74b..60c85691 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -349,18 +349,29 @@ def get_crazy_functions():
print('Load function plugin failed')
try:
- from crazy_functions.图片生成 import 图片生成
+ from crazy_functions.图片生成 import 图片生成, 图片生成_DALLE3
function_plugins.update({
"图片生成(先切换模型到openai或api2d)": {
"Group": "对话",
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
- "ArgsReminder": "在这里输入分辨率, 如256x256(默认)", # 高级参数输入区的显示提示
- "Info": "图片生成 | 输入参数字符串,提供图像的内容",
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认)", # 高级参数输入区的显示提示
+ "Info": "使用DALLE2生成图片 | 输入参数字符串,提供图像的内容",
"Function": HotReload(图片生成)
},
})
+ function_plugins.update({
+ "图片生成_DALLE3(先切换模型到openai或api2d)": {
+ "Group": "对话",
+ "Color": "stop",
+ "AsButton": False,
+ "AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认)", # 高级参数输入区的显示提示
+ "Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
+ "Function": HotReload(图片生成_DALLE3)
+ },
+ })
except:
print('Load function plugin failed')
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index 1b7dff5d..95b44813 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -3,7 +3,7 @@ from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
import datetime
-def gen_image(llm_kwargs, prompt, resolution="256x256"):
+def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
import requests, json, time, os
from request_llms.bridge_all import model_info
@@ -23,6 +23,7 @@ def gen_image(llm_kwargs, prompt, resolution="256x256"):
'prompt': prompt,
'n': 1,
'size': resolution,
+ 'model': model,
'response_format': 'url'
}
response = requests.post(url, headers=headers, json=data, proxies=proxies)
@@ -58,7 +59,7 @@ def 图片生成(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文Prompt。正在处理中 ....."))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
- resolution = plugin_kwargs.get("advanced_arg", '256x256')
+ resolution = plugin_kwargs.get("advanced_arg", '1024x1024')
image_url, image_path = gen_image(llm_kwargs, prompt, resolution)
chatbot.append([prompt,
f'图像中转网址:
`{image_url}`
'+
@@ -67,3 +68,29 @@ def 图片生成(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
f'本地文件预览:

'
])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
+@CatchException
+def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+ """
+ txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
+ llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
+ plugin_kwargs 插件模型的参数,暂时没有用武之地
+ chatbot 聊天显示框的句柄,用于显示给用户
+ history 聊天历史,前情提要
+ system_prompt 给gpt的静默提醒
+ web_port 当前软件运行的端口号
+ """
+ history = [] # 清空历史,以免输入溢出
+ chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文Prompt。正在处理中 ....."))
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
+ if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg")
+ resolution = plugin_kwargs.get("advanced_arg", '1024x1024')
+ image_url, image_path = gen_image(llm_kwargs, prompt, resolution)
+ chatbot.append([prompt,
+ f'图像中转网址:
`{image_url}`
'+
+ f'中转网址预览:

'
+ f'本地文件地址:
`{image_path}`
'+
+ f'本地文件预览:

'
+ ])
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
diff --git a/docs/translate_english.json b/docs/translate_english.json
index 850cae54..44361f02 100644
--- a/docs/translate_english.json
+++ b/docs/translate_english.json
@@ -265,7 +265,7 @@
"例如chatglm&gpt-3.5-turbo&api2d-gpt-4": "e.g. chatglm&gpt-3.5-turbo&api2d-gpt-4",
"先切换模型到openai或api2d": "Switch the model to openai or api2d first",
"在这里输入分辨率": "Enter the resolution here",
- "如256x256": "e.g. 256x256",
+ "如1024x1024": "e.g. 1024x1024",
"默认": "Default",
"建议您复制一个config_private.py放自己的秘密": "We suggest you to copy a config_private.py file to keep your secrets, such as API and proxy URLs, from being accidentally uploaded to Github and seen by others.",
"如API和代理网址": "Such as API and proxy URLs",
diff --git a/docs/translate_japanese.json b/docs/translate_japanese.json
index ae86dc06..29ebcc96 100644
--- a/docs/translate_japanese.json
+++ b/docs/translate_japanese.json
@@ -854,7 +854,7 @@
"查询版本和用户意见": "バージョンとユーザーの意見を検索する",
"提取摘要": "要約を抽出する",
"在gpt输出代码的中途": "GPTがコードを出力する途中で",
- "如256x256": "256x256のように",
+ "如1024x1024": "1024x1024のように",
"概括其内容": "内容を要約する",
"剩下的情况都开头除去": "残りの場合はすべて先頭を除去する",
"至少一个线程任务意外失败": "少なくとも1つのスレッドタスクが予期しない失敗をした",
diff --git a/docs/translate_traditionalchinese.json b/docs/translate_traditionalchinese.json
index a677f108..b75cbdb4 100644
--- a/docs/translate_traditionalchinese.json
+++ b/docs/translate_traditionalchinese.json
@@ -1147,7 +1147,7 @@
"Y+回车=确认": "Y+回車=確認",
"正在同时咨询ChatGPT和ChatGLM……": "正在同時諮詢ChatGPT和ChatGLM……",
"根据 heuristic 规则": "根據heuristic規則",
- "如256x256": "如256x256",
+ "如1024x1024": "如1024x1024",
"函数插件区": "函數插件區",
"*** API_KEY 导入成功": "*** API_KEY 導入成功",
"请对下面的程序文件做一个概述文件名是": "請對下面的程序文件做一個概述文件名是",
From f9fc02948ac360e2906214e274a5ebd4770e8a28 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 21:04:21 +0800
Subject: [PATCH 21/24] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=86=E8=BE=A8?=
=?UTF-8?q?=E7=8E=87=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functional.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/crazy_functional.py b/crazy_functional.py
index 60c85691..e82f3995 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -356,7 +356,7 @@ def get_crazy_functions():
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
- "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认)", # 高级参数输入区的显示提示
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 256x256, 512x512, 1024x1024", # 高级参数输入区的显示提示
"Info": "使用DALLE2生成图片 | 输入参数字符串,提供图像的内容",
"Function": HotReload(图片生成)
},
@@ -367,7 +367,7 @@ def get_crazy_functions():
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
- "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认)", # 高级参数输入区的显示提示
+ "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
"Info": "使用DALLE3生成图片 | 输入参数字符串,提供图像的内容",
"Function": HotReload(图片生成_DALLE3)
},
From 362b545a45352b011adef023e54f9c34a8110fdf Mon Sep 17 00:00:00 2001
From: xiangsam
Date: Fri, 10 Nov 2023 14:25:37 +0000
Subject: [PATCH 22/24] =?UTF-8?q?=E6=9B=B4=E6=94=B9import=20nougat?=
=?UTF-8?q?=E6=97=B6=E6=9C=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/批量翻译PDF文档_NOUGAT.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/crazy_functions/批量翻译PDF文档_NOUGAT.py b/crazy_functions/批量翻译PDF文档_NOUGAT.py
index 50e34c4e..16dfd6bf 100644
--- a/crazy_functions/批量翻译PDF文档_NOUGAT.py
+++ b/crazy_functions/批量翻译PDF文档_NOUGAT.py
@@ -57,22 +57,22 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
"批量翻译PDF文档。函数插件贡献者: Binary-Husky"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
- # 尝试导入依赖,如果缺少依赖,则给出安装建议
- try:
- import nougat
- import tiktoken
- except:
- report_execption(chatbot, history,
- a=f"解析项目: {txt}",
- b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade nougat-ocr tiktoken```。")
- yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
- return
-
# 清空历史,以免输入溢出
history = []
from .crazy_utils import get_files_from_everything
success, file_manifest, project_folder = get_files_from_everything(txt, type='.pdf')
+ if len(file_manifest) > 0:
+ # 尝试导入依赖,如果缺少依赖,则给出安装建议
+ try:
+ import nougat
+ import tiktoken
+ except:
+ report_execption(chatbot, history,
+ a=f"解析项目: {txt}",
+ b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade nougat-ocr tiktoken```。")
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
+ return
success_mmd, file_manifest_mmd, _ = get_files_from_everything(txt, type='.mmd')
success = success or success_mmd
file_manifest += file_manifest_mmd
From da7c03e868b89f71b52444a0565ae4d08e50293a Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 22:54:55 +0800
Subject: [PATCH 23/24] =?UTF-8?q?=E5=9B=BE=E5=83=8F=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functional.py | 17 ++-
.../multi_stage/multi_stage_utils.py | 45 +++++++
crazy_functions/图片生成.py | 125 ++++++++++++++++--
toolbox.py | 7 +-
4 files changed, 176 insertions(+), 18 deletions(-)
create mode 100644 crazy_functions/multi_stage/multi_stage_utils.py
diff --git a/crazy_functional.py b/crazy_functional.py
index e82f3995..2e94570c 100644
--- a/crazy_functional.py
+++ b/crazy_functional.py
@@ -349,16 +349,16 @@ def get_crazy_functions():
print('Load function plugin failed')
try:
- from crazy_functions.图片生成 import 图片生成, 图片生成_DALLE3
+ from crazy_functions.图片生成 import 图片生成_DALLE2, 图片生成_DALLE3, 图片修改_DALLE2
function_plugins.update({
- "图片生成(先切换模型到openai或api2d)": {
+ "图片生成_DALLE2(先切换模型到openai或api2d)": {
"Group": "对话",
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
"ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 256x256, 512x512, 1024x1024", # 高级参数输入区的显示提示
"Info": "使用DALLE2生成图片 | 输入参数字符串,提供图像的内容",
- "Function": HotReload(图片生成)
+ "Function": HotReload(图片生成_DALLE2)
},
})
function_plugins.update({
@@ -372,6 +372,17 @@ def get_crazy_functions():
"Function": HotReload(图片生成_DALLE3)
},
})
+ # function_plugins.update({
+ # "图片修改_DALLE2(启动DALLE2图像修改向导程序)": {
+ # "Group": "对话",
+ # "Color": "stop",
+ # "AsButton": False,
+ # "AdvancedArgs": True, # 调用时,唤起高级参数输入区(默认False)
+ # "ArgsReminder": "在这里输入分辨率, 如1024x1024(默认),支持 1024x1024, 1792x1024, 1024x1792", # 高级参数输入区的显示提示
+ # # "Info": "使用DALLE2修改图片 | 输入参数字符串,提供图像的内容",
+ # "Function": HotReload(图片修改_DALLE2)
+ # },
+ # })
except:
print('Load function plugin failed')
diff --git a/crazy_functions/multi_stage/multi_stage_utils.py b/crazy_functions/multi_stage/multi_stage_utils.py
new file mode 100644
index 00000000..60f07783
--- /dev/null
+++ b/crazy_functions/multi_stage/multi_stage_utils.py
@@ -0,0 +1,45 @@
+from pydantic import BaseModel, Field
+from typing import List
+from toolbox import update_ui_lastest_msg, disable_auto_promotion
+from request_llms.bridge_all import predict_no_ui_long_connection
+from crazy_functions.json_fns.pydantic_io import GptJsonIO, JsonStringError
+import time
+import pickle
+
+def have_any_recent_upload_files(chatbot):
+ _5min = 5 * 60
+ if not chatbot: return False # chatbot is None
+ most_recent_uploaded = chatbot._cookies.get("most_recent_uploaded", None)
+ if not most_recent_uploaded: return False # most_recent_uploaded is None
+ if time.time() - most_recent_uploaded["time"] < _5min: return True # most_recent_uploaded is new
+ else: return False # most_recent_uploaded is too old
+
+class GptAcademicState():
+ def __init__(self):
+ self.reset()
+
+ def reset(self):
+ pass
+
+ def lock_plugin(self, chatbot):
+ chatbot._cookies['plugin_state'] = pickle.dumps(self)
+
+ def unlock_plugin(self, chatbot):
+ self.reset()
+ chatbot._cookies['plugin_state'] = pickle.dumps(self)
+
+ def set_state(self, chatbot, key, value):
+ setattr(self, key, value)
+ chatbot._cookies['plugin_state'] = pickle.dumps(self)
+
+ def get_state(chatbot, cls=None):
+ state = chatbot._cookies.get('plugin_state', None)
+ if state is not None: state = pickle.loads(state)
+ elif cls is not None: state = cls()
+ else: state = GptAcademicState()
+ state.chatbot = chatbot
+ return state
+
+class GatherMaterials():
+ def __init__(self, materials) -> None:
+ materials = ['image', 'prompt']
\ No newline at end of file
diff --git a/crazy_functions/图片生成.py b/crazy_functions/图片生成.py
index 95b44813..4968361a 100644
--- a/crazy_functions/图片生成.py
+++ b/crazy_functions/图片生成.py
@@ -1,6 +1,5 @@
from toolbox import CatchException, update_ui, get_conf, select_api_key, get_log_folder
-from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
-import datetime
+from crazy_functions.multi_stage.multi_stage_utils import GptAcademicState
def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
@@ -43,9 +42,48 @@ def gen_image(llm_kwargs, prompt, resolution="1024x1024", model="dall-e-2"):
return image_url, file_path+file_name
+def edit_image(llm_kwargs, prompt, image_path, resolution="1024x1024", model="dall-e-2"):
+ import requests, json, time, os
+ from request_llms.bridge_all import model_info
+
+ proxies = get_conf('proxies')
+ api_key = select_api_key(llm_kwargs['api_key'], llm_kwargs['llm_model'])
+ chat_endpoint = model_info[llm_kwargs['llm_model']]['endpoint']
+ # 'https://api.openai.com/v1/chat/completions'
+ img_endpoint = chat_endpoint.replace('chat/completions','images/edits')
+ # # Generate the image
+ url = img_endpoint
+ headers = {
+ 'Authorization': f"Bearer {api_key}",
+ 'Content-Type': 'application/json'
+ }
+ data = {
+ 'image': open(image_path, 'rb'),
+ 'prompt': prompt,
+ 'n': 1,
+ 'size': resolution,
+ 'model': model,
+ 'response_format': 'url'
+ }
+ response = requests.post(url, headers=headers, json=data, proxies=proxies)
+ print(response.content)
+ try:
+ image_url = json.loads(response.content.decode('utf8'))['data'][0]['url']
+ except:
+ raise RuntimeError(response.content.decode())
+ # 文件保存到本地
+ r = requests.get(image_url, proxies=proxies)
+ file_path = f'{get_log_folder()}/image_gen/'
+ os.makedirs(file_path, exist_ok=True)
+ file_name = 'Image' + time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.png'
+ with open(file_path+file_name, 'wb+') as f: f.write(r.content)
+
+
+ return image_url, file_path+file_name
+
@CatchException
-def 图片生成(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+def 图片生成_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
@@ -69,17 +107,9 @@ def 图片生成(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
@CatchException
def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
- """
- txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
- llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
- plugin_kwargs 插件模型的参数,暂时没有用武之地
- chatbot 聊天显示框的句柄,用于显示给用户
- history 聊天历史,前情提要
- system_prompt 给gpt的静默提醒
- web_port 当前软件运行的端口号
- """
history = [] # 清空历史,以免输入溢出
chatbot.append(("这是什么功能?", "[Local Message] 生成图像, 请先把模型切换至gpt-*或者api2d-*。如果中文效果不理想, 请尝试英文Prompt。正在处理中 ....."))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
@@ -94,3 +124,74 @@ def 图片生成_DALLE3(prompt, llm_kwargs, plugin_kwargs, chatbot, history, sys
])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
+class ImageEditState(GptAcademicState):
+ def get_image_file(self, x):
+ import os, glob
+ if len(x) == 0: return False, None
+ if not os.path.exists(x): return False, None
+ if x.endswith('.png'): return True, x
+ file_manifest = [f for f in glob.glob(f'{x}/**/*.png', recursive=True)]
+ confirm = (len(file_manifest) >= 1 and file_manifest[0].endswith('.png') and os.path.exists(file_manifest[0]))
+ file = None if not confirm else file_manifest[0]
+ return confirm, file
+
+ def get_resolution(self, x):
+ return (x in ['256x256', '512x512', '1024x1024']), x
+
+ def get_prompt(self, x):
+ confirm = (len(x)>=5) and (not self.get_resolution(x)[0]) and (not self.get_image_file(x)[0])
+ return confirm, x
+
+ def reset(self):
+ self.req = [
+ {'value':None, 'description': '请先上传图像(必须是.png格式), 然后再次点击本插件', 'verify_fn': self.get_image_file},
+ {'value':None, 'description': '请输入分辨率,可选:256x256, 512x512 或 1024x1024', 'verify_fn': self.get_resolution},
+ {'value':None, 'description': '请输入修改需求,建议您使用英文提示词', 'verify_fn': self.get_prompt},
+ ]
+ self.info = ""
+
+ def feed(self, prompt, chatbot):
+ for r in self.req:
+ if r['value'] is None:
+ confirm, res = r['verify_fn'](prompt)
+ if confirm:
+ r['value'] = res
+ self.set_state(chatbot, 'dummy_key', 'dummy_value')
+ break
+ return self
+
+ def next_req(self):
+ for r in self.req:
+ if r['value'] is None:
+ return r['description']
+ return "已经收集到所有信息"
+
+ def already_obtained_all_materials(self):
+ return all([x['value'] is not None for x in self.req])
+
+@CatchException
+def 图片修改_DALLE2(prompt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
+ history = [] # 清空历史
+ state = ImageEditState.get_state(chatbot, ImageEditState)
+ state = state.feed(prompt, chatbot)
+ if not state.already_obtained_all_materials():
+ chatbot.append(["图片修改(先上传图片,再输入修改需求,最后输入分辨率)", state.next_req()])
+ yield from update_ui(chatbot=chatbot, history=history)
+ return
+
+ image_path = state.req[0]
+ resolution = state.req[1]
+ prompt = state.req[2]
+ chatbot.append(["图片修改, 执行中", f"图片:`{image_path}`
分辨率:`{resolution}`
修改需求:`{prompt}`"])
+ yield from update_ui(chatbot=chatbot, history=history)
+
+ image_url, image_path = edit_image(llm_kwargs, prompt, image_path, resolution)
+ chatbot.append([state.prompt,
+ f'图像中转网址:
`{image_url}`
'+
+ f'中转网址预览:
'
+ f'本地文件地址:
`{image_path}`
'+
+ f'本地文件预览:
'
+ ])
+ yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
+
diff --git a/toolbox.py b/toolbox.py
index 8c6e7fae..b1e1ce7b 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -625,13 +625,14 @@ def on_file_uploaded(request: gradio.Request, files, chatbot, txt, txt2, checkbo
def on_report_generated(cookies, files, chatbot):
- from toolbox import find_recent_files
- PATH_LOGGING = get_conf('PATH_LOGGING')
+ # from toolbox import find_recent_files
+ # PATH_LOGGING = get_conf('PATH_LOGGING')
if 'files_to_promote' in cookies:
report_files = cookies['files_to_promote']
cookies.pop('files_to_promote')
else:
- report_files = find_recent_files(PATH_LOGGING)
+ report_files = []
+ # report_files = find_recent_files(PATH_LOGGING)
if len(report_files) == 0:
return cookies, None, chatbot
# files.extend(report_files)
From 107ea868e15eac1687fc18249f55f09b4fdff207 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Fri, 10 Nov 2023 23:08:56 +0800
Subject: [PATCH 24/24] =?UTF-8?q?API2D=E8=87=AA=E5=8A=A8=E5=AF=B9=E9=BD=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config.py | 4 ++--
request_llms/bridge_all.py | 22 ++++++++++------------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/config.py b/config.py
index 38d05198..611b1589 100644
--- a/config.py
+++ b/config.py
@@ -89,8 +89,8 @@ DEFAULT_FN_GROUPS = ['对话', '编程', '学术', '智能体']
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
AVAIL_LLM_MODELS = ["gpt-3.5-turbo-1106","gpt-4-1106-preview",
"gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
- "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
- "gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
+ "api2d-gpt-3.5-turbo", 'api2d-gpt-3.5-turbo-16k',
+ "gpt-4", "gpt-4-32k", "azure-gpt-4", "api2d-gpt-4",
"chatglm3", "moss", "newbing", "claude-2"]
# P.S. 其他可用的模型还包括 ["zhipuai", "qianfan", "llama2", "qwen", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613", "gpt-3.5-random"
# "spark", "sparkv2", "sparkv3", "chatglm_onnx", "claude-1-100k", "claude-2", "internlm", "jittorllms_pangualpha", "jittorllms_llama"]
diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py
index 5da44b79..139d3ae9 100644
--- a/request_llms/bridge_all.py
+++ b/request_llms/bridge_all.py
@@ -177,11 +177,11 @@ model_info = {
"fn_without_ui": chatgpt_noui,
"endpoint": azure_endpoint,
"max_token": 8192,
- "tokenizer": tokenizer_gpt35,
- "token_cnt": get_token_num_gpt35,
+ "tokenizer": tokenizer_gpt4,
+ "token_cnt": get_token_num_gpt4,
},
- # api_2d
+ # api_2d (此后不需要在此处添加api2d的接口了,因为下面的代码会自动添加)
"api2d-gpt-3.5-turbo": {
"fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui,
@@ -200,15 +200,6 @@ model_info = {
"token_cnt": get_token_num_gpt4,
},
- "api2d-gpt-3.5-turbo-16k": {
- "fn_with_ui": chatgpt_ui,
- "fn_without_ui": chatgpt_noui,
- "endpoint": api2d_endpoint,
- "max_token": 16385,
- "tokenizer": tokenizer_gpt35,
- "token_cnt": get_token_num_gpt35,
- },
-
# 将 chatglm 直接对齐到 chatglm2
"chatglm": {
"fn_with_ui": chatglm_ui,
@@ -244,6 +235,13 @@ model_info = {
},
}
+# -=-=-=-=-=-=- api2d 对齐支持 -=-=-=-=-=-=-
+for model in AVAIL_LLM_MODELS:
+ if model.startswith('api2d-') and (model.replace('api2d-','') in model_info.keys()):
+ mi = model_info[model.replace('api2d-','')]
+ mi.update({"endpoint": api2d_endpoint})
+ model_info.update({model: mi})
+
# -=-=-=-=-=-=- 以下部分是新加入的模型,可能附带额外依赖 -=-=-=-=-=-=-
if "claude-1-100k" in AVAIL_LLM_MODELS or "claude-2" in AVAIL_LLM_MODELS:
from .bridge_claude import predict_no_ui_long_connection as claude_noui