lewisliuX123 commited on
Commit
b2938eb
1 Parent(s): 7b9990e

Update bot/chatgpt/chat_gpt_bot.py

Browse files
Files changed (1) hide show
  1. bot/chatgpt/chat_gpt_bot.py +17 -17
bot/chatgpt/chat_gpt_bot.py CHANGED
@@ -54,15 +54,15 @@ class ChatGPTBot(Bot):
54
  logger.info(response.choices[0]['message']['content'])
55
  # log.info("[OPEN_AI] reply={}".format(res_content))
56
  return response.choices[0]['message']['content']
57
- except openai.error.RateLimitError as e:
58
- # rate limit exception
59
- logger.warn(e)
60
- if retry_count < 3:
61
- time.sleep(5)
62
- logger.warn("[OPEN_AI] RateLimit exceed, 第{}次重试".format(retry_count+1))
63
- return self.reply_text(query, user_id, retry_count+1)
64
- else:
65
- return "问太快了,慢点行不行"
66
  except Exception as e:
67
  # unknown exception
68
  logger.exception(e)
@@ -80,14 +80,14 @@ class ChatGPTBot(Bot):
80
  image_url = response['data'][0]['url']
81
  logger.info("[OPEN_AI] image_url={}".format(image_url))
82
  return image_url
83
- except openai.error.RateLimitError as e:
84
- logger.warn(e)
85
- if retry_count < 3:
86
- time.sleep(5)
87
- logger.warn("[OPEN_AI] ImgCreate RateLimit exceed, 第{}次重试".format(retry_count+1))
88
- return self.reply_text(query, retry_count+1)
89
- else:
90
- return "问太快了,慢点行不行"
91
  except Exception as e:
92
  logger.exception(e)
93
  return None
 
54
  logger.info(response.choices[0]['message']['content'])
55
  # log.info("[OPEN_AI] reply={}".format(res_content))
56
  return response.choices[0]['message']['content']
57
+ # except openai.error.RateLimitError as e:
58
+ # # rate limit exception
59
+ # logger.warn(e)
60
+ # if retry_count < 3:
61
+ # time.sleep(5)
62
+ # logger.warn("[OPEN_AI] RateLimit exceed, 第{}次重试".format(retry_count+1))
63
+ # return self.reply_text(query, user_id, retry_count+1)
64
+ # else:
65
+ # return "问太快了,慢点行不行"
66
  except Exception as e:
67
  # unknown exception
68
  logger.exception(e)
 
80
  image_url = response['data'][0]['url']
81
  logger.info("[OPEN_AI] image_url={}".format(image_url))
82
  return image_url
83
+ # except openai.error.RateLimitError as e:
84
+ # logger.warn(e)
85
+ # if retry_count < 3:
86
+ # time.sleep(5)
87
+ # logger.warn("[OPEN_AI] ImgCreate RateLimit exceed, 第{}次重试".format(retry_count+1))
88
+ # return self.reply_text(query, retry_count+1)
89
+ # else:
90
+ # return "问太快了,慢点行不行"
91
  except Exception as e:
92
  logger.exception(e)
93
  return None