bstraehle commited on
Commit
cfbcfed
·
verified ·
1 Parent(s): 2c1f763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,8 +1,10 @@
1
  import gradio as gr
2
- import agentops, os
3
 
4
  from crew import get_crew
5
 
 
 
6
  LLM = "gpt-4o"
7
 
8
  def invoke(openai_api_key, topic):
@@ -13,15 +15,18 @@ def invoke(openai_api_key, topic):
13
 
14
  agentops.init(os.environ["AGENTOPS_API_KEY"])
15
 
16
- os.environ["OPENAI_API_KEY"] = openai_api_key
17
-
18
- article = get_crew(LLM).kickoff(inputs={"topic": topic})
19
-
20
- #print("===")
21
- #print(article)
22
- #print("===")
23
-
24
- return article
 
 
 
25
 
26
  gr.close_all()
27
 
 
1
  import gradio as gr
2
+ import agentops, os, threading
3
 
4
  from crew import get_crew
5
 
6
+ lock = threading.Lock()
7
+
8
  LLM = "gpt-4o"
9
 
10
  def invoke(openai_api_key, topic):
 
15
 
16
  agentops.init(os.environ["AGENTOPS_API_KEY"])
17
 
18
+ with lock:
19
+ os.environ["OPENAI_API_KEY"] = openai_api_key
20
+
21
+ article = get_crew(LLM).kickoff(inputs={"topic": topic})
22
+
23
+ #print("===")
24
+ #print(article)
25
+ #print("===")
26
+
27
+ del os.environ["OPENAI_API_KEY"]
28
+
29
+ return article
30
 
31
  gr.close_all()
32