roseyai commited on
Commit
de746ec
·
1 Parent(s): 53cc70f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -209,7 +209,8 @@ def set_openai_api_key(api_key):
209
  """Set the api key and return chain.
210
  If no api_key, then None is returned.
211
  """
212
- if api_key and api_key.startswith("sk-") and len(api_key) > 50:
 
213
  os.environ["OPENAI_API_KEY"] = api_key
214
  llm = OpenAI(temperature=0, max_tokens=MAX_TOKENS)
215
  chain, express_chain = load_chain(TOOLS_DEFAULT_LIST, llm)
@@ -307,7 +308,7 @@ class ChatWrapper:
307
  if chain and chain != "":
308
  # Set OpenAI key
309
  import openai
310
- openai.api_key = "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"
311
  output, hidden_text = run_chain(chain, inp, capture_hidden_text=trace_chain)
312
 
313
  output = transform_text(output, express_chain, num_words, formality, anticipation_level, joy_level, trust_level,
 
209
  """Set the api key and return chain.
210
  If no api_key, then None is returned.
211
  """
212
+ api_key = os.environ["OPENAI_API_KEY"]
213
+ if api_key and len(api_key) > 1:
214
  os.environ["OPENAI_API_KEY"] = api_key
215
  llm = OpenAI(temperature=0, max_tokens=MAX_TOKENS)
216
  chain, express_chain = load_chain(TOOLS_DEFAULT_LIST, llm)
 
308
  if chain and chain != "":
309
  # Set OpenAI key
310
  import openai
311
+ openai.api_key = api_key
312
  output, hidden_text = run_chain(chain, inp, capture_hidden_text=trace_chain)
313
 
314
  output = transform_text(output, express_chain, num_words, formality, anticipation_level, joy_level, trust_level,