appl044 commited on
Commit
3561d48
1 Parent(s): 6d95d66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -28
app.py CHANGED
@@ -266,7 +266,7 @@ def load_chain(tools_list, llm):
266
 
267
 
268
  # async def set_chain_state_api_key(api_key):
269
- def set_openai_key(api_key):
270
  # Set the API key for chain_state
271
  # chain_state.api_key = api_key
272
 
@@ -289,7 +289,7 @@ def set_openai_key(api_key):
289
  # async def set_memory_state_api_key(api_key):
290
  # Set the API key for memory_state
291
  # memory_state.api_key = api_key
292
-
293
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
294
  os.environ["OPENAI_API_KEY"] = api_key
295
  print("\n\n ++++++++++++++ Setting OpenAI API key ++++++++++++++ \n\n")
@@ -312,32 +312,6 @@ def set_openai_key(api_key):
312
 
313
  PROMPTLAYER_API_BASE = "https://api.promptlayer.com"
314
 
315
-
316
- # async def set_openai_api_key(api_key):
317
- def set_openai_api_key(api_key):
318
- """
319
- Sets the OpenAI API key for various components in the application asynchronously.
320
-
321
- Args:
322
- api_key (str): The OpenAI API key.
323
-
324
- Side effects:
325
- Updates the API key for chain_state, express_chain_state, llm_state,
326
- embeddings_state, qa_chain_state, and memory_state.
327
- """
328
- try:
329
- await set_openai_key(api_key)
330
- # await set_chain_state_api_key(api_key)
331
- # await set_express_chain_state_api_key(api_key)
332
- # await set_llm_state_api_key(api_key)
333
- # await set_embeddings_state_api_key(api_key)
334
- # await set_qa_chain_state_api_key(api_key)
335
- # await set_memory_state_api_key(api_key)
336
- except Exception as e:
337
- # Handle the error, e.g., log the error message or show an alert to the user
338
- print(f"Error setting OpenAI API key: {e}")
339
-
340
-
341
  def run_chain(chain, inp, capture_hidden_text):
342
  output = ""
343
  hidden_text = None
 
266
 
267
 
268
  # async def set_chain_state_api_key(api_key):
269
+ # def set_openai_key(api_key):
270
  # Set the API key for chain_state
271
  # chain_state.api_key = api_key
272
 
 
289
  # async def set_memory_state_api_key(api_key):
290
  # Set the API key for memory_state
291
  # memory_state.api_key = api_key
292
+ def set_openai_api_key(api_key):
293
  if api_key and api_key.startswith("sk-") and len(api_key) > 50:
294
  os.environ["OPENAI_API_KEY"] = api_key
295
  print("\n\n ++++++++++++++ Setting OpenAI API key ++++++++++++++ \n\n")
 
312
 
313
  PROMPTLAYER_API_BASE = "https://api.promptlayer.com"
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  def run_chain(chain, inp, capture_hidden_text):
316
  output = ""
317
  hidden_text = None