Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import agentops,
|
| 3 |
|
| 4 |
from crew import get_crew
|
| 5 |
-
from openai import OpenAI
|
| 6 |
|
| 7 |
def invoke(openai_api_key, serper_api_key, topic):
|
| 8 |
if (openai_api_key == ""):
|
|
@@ -12,26 +12,21 @@ def invoke(openai_api_key, serper_api_key, topic):
|
|
| 12 |
if (topic == ""):
|
| 13 |
raise gr.Error("Topic is required.")
|
| 14 |
|
| 15 |
-
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 16 |
-
os.environ["SERPER_API_KEY"] = serper_api_key
|
| 17 |
|
| 18 |
-
OPENAI_API_KEY =
|
| 19 |
-
AGENTOPS_API_KEY =
|
| 20 |
-
logging.basicConfig(level=logging.DEBUG)
|
| 21 |
-
openai = OpenAI(api_key=OPENAI_API_KEY)
|
| 22 |
-
agentops.init(AGENTOPS_API_KEY)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
'risk_tolerance': 'Medium',
|
| 28 |
-
'trading_strategy_preference': 'Day Trading',
|
| 29 |
-
'news_impact_consideration': True
|
| 30 |
-
}
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> SDK
|
| 35 |
with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
|
| 36 |
|
| 37 |
gr.close_all()
|
|
@@ -39,9 +34,9 @@ gr.close_all()
|
|
| 39 |
demo = gr.Interface(fn = invoke,
|
| 40 |
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
|
| 41 |
gr.Textbox(label = "Serper API Key", type = "password", lines = 1),
|
| 42 |
-
gr.Textbox(label = "Topic", value="
|
| 43 |
outputs = [gr.Textbox(label = "Output", lines = 1)],
|
| 44 |
-
title = "Agentic
|
| 45 |
description = description)
|
| 46 |
|
| 47 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import agentops, os
|
| 3 |
|
| 4 |
from crew import get_crew
|
| 5 |
+
#from openai import OpenAI
|
| 6 |
|
| 7 |
def invoke(openai_api_key, serper_api_key, topic):
|
| 8 |
if (openai_api_key == ""):
|
|
|
|
| 12 |
if (topic == ""):
|
| 13 |
raise gr.Error("Topic is required.")
|
| 14 |
|
| 15 |
+
#os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 16 |
+
#os.environ["SERPER_API_KEY"] = serper_api_key
|
| 17 |
|
| 18 |
+
OPENAI_API_KEY = openai_api_key
|
| 19 |
+
AGENTOPS_API_KEY = serper_api_key
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
#logging.basicConfig(level=logging.DEBUG)
|
| 22 |
+
|
| 23 |
+
#openai = OpenAI(api_key=OPENAI_API_KEY)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
agentops.init(AGENTOPS_API_KEY)
|
| 26 |
+
|
| 27 |
+
return get_crew().kickoff(inputs={"topic": topic})
|
| 28 |
|
| 29 |
+
description = """TODO <a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> SDK
|
| 30 |
with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
|
| 31 |
|
| 32 |
gr.close_all()
|
|
|
|
| 34 |
demo = gr.Interface(fn = invoke,
|
| 35 |
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
|
| 36 |
gr.Textbox(label = "Serper API Key", type = "password", lines = 1),
|
| 37 |
+
gr.Textbox(label = "Topic", value="Evolution of GenAI/LLM/RAG from naive RAG to advanced RAG to agentic RAG.", lines = 1)],
|
| 38 |
outputs = [gr.Textbox(label = "Output", lines = 1)],
|
| 39 |
+
title = "Agentic RAG: LinkedIn Post Generation",
|
| 40 |
description = description)
|
| 41 |
|
| 42 |
demo.launch()
|