bstraehle commited on
Commit
76095d5
·
verified ·
1 Parent(s): 86b3f38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import os, threading
2
  import gradio as gr
3
  from agents.crew import run_crew
4
  from utils.utils import get_questions
@@ -36,26 +36,18 @@ def ask(question, openai_api_key, gemini_api_key, anthropic_api_key, file_name =
36
  if file_name:
37
  file_name = f"data/{file_name}"
38
 
39
- lock = threading.Lock()
40
-
41
- with lock:
42
- answer = ""
43
-
44
- try:
45
- os.environ["OPENAI_API_KEY"] = openai_api_key
46
- os.environ["GEMINI_API_KEY"] = gemini_api_key
47
- os.environ["MODEL_API_KEY"] = anthropic_api_key
48
-
49
- answer = run_crew(question, file_name)
50
- except Exception as e:
51
- gr.Warning(e)
52
- return ""
53
- finally:
54
- del os.environ["OPENAI_API_KEY"]
55
- del os.environ["GEMINI_API_KEY"]
56
- del os.environ["MODEL_API_KEY"]
57
 
58
- return answer
 
 
 
 
 
 
59
 
60
  gr.close_all()
61
 
 
1
+ import os
2
  import gradio as gr
3
  from agents.crew import run_crew
4
  from utils.utils import get_questions
 
36
  if file_name:
37
  file_name = f"data/{file_name}"
38
 
39
+ try:
40
+ os.environ["OPENAI_API_KEY"] = openai_api_key
41
+ os.environ["GEMINI_API_KEY"] = gemini_api_key
42
+ os.environ["MODEL_API_KEY"] = anthropic_api_key
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ return run_crew(question, file_name)
45
+ except Exception as e:
46
+ gr.Warning(str(e))
47
+ return ""
48
+ finally:
49
+ for key in ["OPENAI_API_KEY", "GEMINI_API_KEY", "MODEL_API_KEY"]:
50
+ os.environ.pop(key, None)
51
 
52
  gr.close_all()
53