Spaces:
Sleeping
Sleeping
替换基础函数
Browse files- crazy_functions/高级功能函数模板.py +8 -12
crazy_functions/高级功能函数模板.py
CHANGED
|
@@ -1,25 +1,21 @@
|
|
| 1 |
from request_llm.bridge_chatgpt import predict_no_ui_long_connection
|
| 2 |
from toolbox import CatchException
|
|
|
|
| 3 |
import datetime
|
| 4 |
-
|
| 5 |
@CatchException
|
| 6 |
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
| 7 |
history = [] # 清空历史,以免输入溢出
|
| 8 |
-
chatbot.append(("这是什么功能?", "[Local Message] 请注意,您正在调用一个[函数插件]
|
| 9 |
yield chatbot, history, '正常' # 由于请求gpt需要一段时间,我们先及时地做一次状态显示
|
| 10 |
-
|
| 11 |
for i in range(5):
|
| 12 |
currentMonth = (datetime.date.today() + datetime.timedelta(days=i)).month
|
| 13 |
currentDay = (datetime.date.today() + datetime.timedelta(days=i)).day
|
| 14 |
i_say = f'历史中哪些事件发生在{currentMonth}月{currentDay}日?列举两条并发送相关图片。发送图片时,请使用Markdown,将Unsplash API中的PUT_YOUR_QUERY_HERE替换成描述该事件的一个最重要的单词。'
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
sys_prompt="当你想发送一张照片时,请使用Markdown, 并且不要有反斜线, 不要用代码块。使用 Unsplash API (https://source.unsplash.com/1280x720/? < PUT_YOUR_QUERY_HERE >)。") # 请求gpt,需要一段时间
|
| 21 |
-
except:
|
| 22 |
-
print("")
|
| 23 |
chatbot[-1] = (i_say, gpt_say)
|
| 24 |
history.append(i_say);history.append(gpt_say)
|
| 25 |
-
yield chatbot, history, '正常'
|
|
|
|
| 1 |
from request_llm.bridge_chatgpt import predict_no_ui_long_connection
|
| 2 |
from toolbox import CatchException
|
| 3 |
+
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
| 4 |
import datetime
|
|
|
|
| 5 |
@CatchException
|
| 6 |
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
| 7 |
history = [] # 清空历史,以免输入溢出
|
| 8 |
+
chatbot.append(("这是什么功能?", "[Local Message] 请注意,您正在调用一个[函数插件]的模板,该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板(该函数只有21行代码)。此外我们也提供可同步处理大量文件的多线程Demo供您参考。您若希望分享新的功能模组,请不吝PR!"))
|
| 9 |
yield chatbot, history, '正常' # 由于请求gpt需要一段时间,我们先及时地做一次状态显示
|
|
|
|
| 10 |
for i in range(5):
|
| 11 |
currentMonth = (datetime.date.today() + datetime.timedelta(days=i)).month
|
| 12 |
currentDay = (datetime.date.today() + datetime.timedelta(days=i)).day
|
| 13 |
i_say = f'历史中哪些事件发生在{currentMonth}月{currentDay}日?列举两条并发送相关图片。发送图片时,请使用Markdown,将Unsplash API中的PUT_YOUR_QUERY_HERE替换成描述该事件的一个最重要的单词。'
|
| 14 |
+
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
|
| 15 |
+
inputs=i_say, inputs_show_user=i_say,
|
| 16 |
+
top_p=top_p, temperature=temperature, chatbot=chatbot, history=[],
|
| 17 |
+
sys_prompt="当你想发送一张照片时,请使用Markdown, 并且不要有反斜线, 不要用代码块。使用 Unsplash API (https://source.unsplash.com/1280x720/? < PUT_YOUR_QUERY_HERE >)。"
|
| 18 |
+
)
|
|
|
|
|
|
|
|
|
|
| 19 |
chatbot[-1] = (i_say, gpt_say)
|
| 20 |
history.append(i_say);history.append(gpt_say)
|
| 21 |
+
yield chatbot, history, '正常'
|