JLW commited on
Commit
c8f82bd
·
1 Parent(s): 010cf64

Try to identify condition in which users seemingly in error get the "Please paste API key message"

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -39,7 +39,8 @@ TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'ne
39
  'open-meteo-api'] # 'google-search'
40
  TOOLS_DEFAULT_LIST = ['serpapi', 'pal-math']
41
  BUG_FOUND_MSG = "Congratulations, you've found a bug in this application!"
42
- AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
 
43
  MAX_TOKENS = 512
44
 
45
  LOOPING_TALKING_HEAD = "videos/Masahiro.mp4"
@@ -244,7 +245,8 @@ def run_chain(chain, inp, capture_hidden_text):
244
  try:
245
  output = chain.run(input=inp)
246
  except AuthenticationError as ae:
247
- error_msg = AUTH_ERR_MSG
 
248
  except RateLimitError as rle:
249
  error_msg = "\n\nRateLimitError: " + str(rle)
250
  except ValueError as ve:
@@ -317,8 +319,7 @@ class ChatWrapper:
317
  print("monologue: ", monologue)
318
  history = history or []
319
  # If chain is None, that is because no API key was provided.
320
- output = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or " \
321
- "key after pasting it."
322
  hidden_text = output
323
 
324
  if chain and chain != "":
 
39
  'open-meteo-api'] # 'google-search'
40
  TOOLS_DEFAULT_LIST = ['serpapi', 'pal-math']
41
  BUG_FOUND_MSG = "Congratulations, you've found a bug in this application!"
42
+ # AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
43
+ AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
44
  MAX_TOKENS = 512
45
 
46
  LOOPING_TALKING_HEAD = "videos/Masahiro.mp4"
 
245
  try:
246
  output = chain.run(input=inp)
247
  except AuthenticationError as ae:
248
+ error_msg = AUTH_ERR_MSG + str(datetime.datetime.now()) + ". " + str(ae)
249
+ print("error_msg", error_msg)
250
  except RateLimitError as rle:
251
  error_msg = "\n\nRateLimitError: " + str(rle)
252
  except ValueError as ve:
 
319
  print("monologue: ", monologue)
320
  history = history or []
321
  # If chain is None, that is because no API key was provided.
322
+ output = "Please paste your OpenAI key from openai.com to use this app. " + str(datetime.datetime.now())
 
323
  hidden_text = output
324
 
325
  if chain and chain != "":