xiaolv commited on
Commit
955a0ae
1 Parent(s): 712cb30

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -3,6 +3,7 @@ import json
3
  import asyncio
4
  import os
5
  from EdgeGPT import Chatbot, ConversationStyle
 
6
  import re
7
 
8
  """
@@ -37,6 +38,13 @@ async def get_model_reply(prompt,style,cookies,context=[]):
37
  responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
38
  return responses, context
39
 
 
 
 
 
 
 
 
40
  except:
41
  try:
42
  if raw_data["item"]["throttling"]["numUserMessagesInConversation"] > raw_data["item"]["throttling"][
@@ -48,21 +56,12 @@ async def get_model_reply(prompt,style,cookies,context=[]):
48
  return responses, context
49
 
50
  except:
51
- try:
52
- if 'error' in raw_data:
53
- if raw_data['error'] == 'Authentication failed. You have not been accepted into the beta.':
54
- response = " >>>> 账号需要重新激活。"
55
- print(response)
56
- context += ["-1"]
57
- responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
58
- return responses, context
59
- except:
60
- if raw_data["item"]["result"]["value"] == "Throttled":
61
- response = "> **错误: 我们很抱歉,但你已经达到了你在24小时内可以向Bing发送消息的最大数量。请稍后再查看!**"
62
- print(response)
63
- context += ["1"]
64
- responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
65
- return responses, context
66
 
67
 
68
  with gr.Blocks() as dialog_app:
 
3
  import asyncio
4
  import os
5
  from EdgeGPT import Chatbot, ConversationStyle
6
+ import EdgeGPT
7
  import re
8
 
9
  """
 
38
  responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
39
  return responses, context
40
 
41
+ except EdgeGPT.NotAllowedToAccess :
42
+ response = " >>>> 账号需要重新激活。"
43
+ print(response)
44
+ context += ["-1"]
45
+ responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
46
+ return responses, context
47
+
48
  except:
49
  try:
50
  if raw_data["item"]["throttling"]["numUserMessagesInConversation"] > raw_data["item"]["throttling"][
 
56
  return responses, context
57
 
58
  except:
59
+ if raw_data["item"]["result"]["value"] == "Throttled":
60
+ response = "> **错误: 我们很抱歉,但你已经达到了你在24小时内可以向Bing发送消息的最大数量。请稍后再查看!**"
61
+ print(response)
62
+ context += ["1"]
63
+ responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
64
+ return responses, context
 
 
 
 
 
 
 
 
 
65
 
66
 
67
  with gr.Blocks() as dialog_app: