JLW commited on
Commit
fd2cb83
·
1 Parent(s): e5ecb05

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 +3 -0
app.py CHANGED
@@ -226,8 +226,11 @@ def set_openai_api_key(api_key):
226
  """
227
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
228
  os.environ["OPENAI_API_KEY"] = api_key
 
229
  llm = OpenAI(temperature=0, max_tokens=MAX_TOKENS)
 
230
  chain, express_chain = load_chain(TOOLS_DEFAULT_LIST, llm)
 
231
  os.environ["OPENAI_API_KEY"] = ""
232
  return chain, express_chain, llm
233
  return None, None, None
 
226
  """
227
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
228
  os.environ["OPENAI_API_KEY"] = api_key
229
+ print(str(datetime.datetime.now()) + ": Before OpenAI, OPENAI_API_KEY length: " + str(len(os.environ["OPENAI_API_KEY"])))
230
  llm = OpenAI(temperature=0, max_tokens=MAX_TOKENS)
231
+ print(str(datetime.datetime.now()) + ": After OpenAI, OPENAI_API_KEY length: " + str(len(os.environ["OPENAI_API_KEY"])))
232
  chain, express_chain = load_chain(TOOLS_DEFAULT_LIST, llm)
233
+ print(str(datetime.datetime.now()) + ": After load_chain, OPENAI_API_KEY length: " + str(len(os.environ["OPENAI_API_KEY"])))
234
  os.environ["OPENAI_API_KEY"] = ""
235
  return chain, express_chain, llm
236
  return None, None, None