Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
|