Spaces:
Runtime error
Runtime error
在chatbot的标签上显示当前的模型选择
Browse files- README.md +1 -1
- main.py +4 -1
- toolbox.py +3 -1
README.md
CHANGED
@@ -12,7 +12,7 @@ If you like this project, please give it a Star. If you've come up with more use
|
|
12 |
>
|
13 |
> 2.本项目中每个文件的功能都在自译解[`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题汇总在[`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)当中。
|
14 |
>
|
15 |
-
|
16 |
|
17 |
<div align="center">
|
18 |
|
|
|
12 |
>
|
13 |
> 2.本项目中每个文件的功能都在自译解[`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题汇总在[`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)当中。
|
14 |
>
|
15 |
+
> 3.已支持OpenAI和API2D的api-key共存,可在配置文件中填写如`API_KEY="openai-key1,openai-key2,api2d-key3"`。需要临时更换`API_KEY`时,在输入区输入临时的`API_KEY`然后回车键提交后即可生效。
|
16 |
|
17 |
<div align="center">
|
18 |
|
main.py
CHANGED
@@ -56,7 +56,7 @@ def main():
|
|
56 |
cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL})
|
57 |
with gr_L1():
|
58 |
with gr_L2(scale=2):
|
59 |
-
chatbot = gr.Chatbot()
|
60 |
chatbot.style(height=CHATBOT_HEIGHT)
|
61 |
history = gr.State([])
|
62 |
with gr_L2(scale=1):
|
@@ -155,6 +155,9 @@ def main():
|
|
155 |
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
|
156 |
return {switchy_bt: gr.update(value=k, variant=variant)}
|
157 |
dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] )
|
|
|
|
|
|
|
158 |
# 随变按钮的回调函数注册
|
159 |
def route(k, *args, **kwargs):
|
160 |
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
|
|
56 |
cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL})
|
57 |
with gr_L1():
|
58 |
with gr_L2(scale=2):
|
59 |
+
chatbot = gr.Chatbot(label=f"当前模型:{LLM_MODEL}")
|
60 |
chatbot.style(height=CHATBOT_HEIGHT)
|
61 |
history = gr.State([])
|
62 |
with gr_L2(scale=1):
|
|
|
155 |
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
|
156 |
return {switchy_bt: gr.update(value=k, variant=variant)}
|
157 |
dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] )
|
158 |
+
def on_md_dropdown_changed(k):
|
159 |
+
return {chatbot: gr.update(label="当前模型:"+k)}
|
160 |
+
md_dropdown.select(on_md_dropdown_changed, [md_dropdown], [chatbot] )
|
161 |
# 随变按钮的回调函数注册
|
162 |
def route(k, *args, **kwargs):
|
163 |
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
|
toolbox.py
CHANGED
@@ -454,13 +454,15 @@ def select_api_key(keys, llm_model):
|
|
454 |
|
455 |
@lru_cache(maxsize=128)
|
456 |
def read_single_conf_with_lru_cache(arg):
|
457 |
-
from colorful import print亮红, print
|
458 |
try:
|
459 |
r = getattr(importlib.import_module('config_private'), arg)
|
460 |
except:
|
461 |
r = getattr(importlib.import_module('config'), arg)
|
462 |
# 在读取API_KEY时,检查一下是不是忘了改config
|
463 |
if arg == 'API_KEY':
|
|
|
|
|
464 |
if is_any_api_key(r):
|
465 |
print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
|
466 |
else:
|
|
|
454 |
|
455 |
@lru_cache(maxsize=128)
|
456 |
def read_single_conf_with_lru_cache(arg):
|
457 |
+
from colorful import print亮红, print亮绿, print亮蓝
|
458 |
try:
|
459 |
r = getattr(importlib.import_module('config_private'), arg)
|
460 |
except:
|
461 |
r = getattr(importlib.import_module('config'), arg)
|
462 |
# 在读取API_KEY时,检查一下是不是忘了改config
|
463 |
if arg == 'API_KEY':
|
464 |
+
print亮蓝(f"[API_KEY] 本项目现已支持OpenAI和API2D的api-key。也支持同时填写多个api-key,如API_KEY=\"openai-key1,openai-key2,api2d-key3\"")
|
465 |
+
print亮蓝(f"[API_KEY] 您既可以在config.py中修改api-key(s),也可以在问题输入区输入临时的api-key(s),然后回车键提交后即可生效。")
|
466 |
if is_any_api_key(r):
|
467 |
print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
|
468 |
else:
|