xiaolv commited on
Commit
ad6848c
1 Parent(s): a38872f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -30,10 +30,20 @@ async def get_model_reply(prompt,style,cookies,context=[]):
30
  # continue the text up to 2048 tokens ~ 8192 charaters
31
 
32
  try:
33
- bot = Chatbot(cookies=cookies)
34
- raw_data = await bot.ask(prompt, conversation_style=style)
35
- await bot.close()
36
- print(raw_data)
 
 
 
 
 
 
 
 
 
 
37
 
38
  try:
39
  response = raw_data["item"]["messages"][1]["text"]
 
30
  # continue the text up to 2048 tokens ~ 8192 charaters
31
 
32
  try:
33
+ try:
34
+ bot = Chatbot(cookies=cookies)
35
+ raw_data = await bot.ask(prompt, conversation_style=style)
36
+ await bot.close()
37
+ print(raw_data)
38
+
39
+ except Exception as e:
40
+ print(f">>>>>> 报错信息:\t -----> 【{e}】")
41
+ if "throttled" in str(e):
42
+ response = "> **错误: 我们很抱歉,但你已经达到了你在24小时内可以向Bing发送消息的最大数量。请稍后再查看!**"
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
  try:
49
  response = raw_data["item"]["messages"][1]["text"]