lanvent пре 3 година
родитељ
комит
2f78c072d7
2 измењених фајлова са 8 додато и 6 уклоњено
  1. 1 1
      bot/chatgpt/chat_gpt_bot.py
  2. 7 5
      channel/terminal/terminal_channel.py

+ 1 - 1
bot/chatgpt/chat_gpt_bot.py

@@ -127,7 +127,7 @@ class ChatGPTBot(Bot):
     def create_img(self, query, retry_count=0):
         try:
             if conf().get('rate_limit_dalle') and not self.tb4dalle.get_token():
-                return "请求太快了,请休息一下再问我吧"
+                return False, "请求太快了,请休息一下再问我吧"
             logger.info("[OPEN_AI] image_query={}".format(query))
             response = openai.Image.create(
                 prompt=query,    #图片描述

+ 7 - 5
channel/terminal/terminal_channel.py

@@ -1,9 +1,10 @@
+from bridge.context import *
 from channel.channel import Channel
 import sys
 
 class TerminalChannel(Channel):
     def startup(self):
-        context = {"from_user_id": "User"}
+        context = Context()
         print("\nPlease input your question")
         while True:
             try:
@@ -12,12 +13,13 @@ class TerminalChannel(Channel):
                 print("\nExiting...")
                 sys.exit()
 
+            context.type = ContextType.TEXT
+            context['session_id'] = "User"
+            context.content = prompt
             print("Bot:")
             sys.stdout.flush()
-            for res in super().build_reply_content(prompt, context):
-                print(res, end="")
-                sys.stdout.flush()
-            print("\n")
+            res = super().build_reply_content(prompt, context).content
+            print(res)
 
 
     def get_input(self, prompt):