Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,6 @@ load_dotenv()
|
|
12 |
# Access the Groq API key
|
13 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
14 |
|
15 |
-
# Create the agent
|
16 |
agent = Agent(
|
17 |
model=Groq(id="llama-3.3-70b-versatile", api_key=groq_api_key),
|
18 |
tools=[DuckDuckGo(), Newspaper4k()],
|
@@ -25,30 +24,18 @@ agent = Agent(
|
|
25 |
markdown=True,
|
26 |
show_tool_calls=True,
|
27 |
add_datetime_to_instructions=True,
|
|
|
28 |
)
|
29 |
|
30 |
-
# Function to process input and generate an article
|
31 |
def generate_article(topic):
|
32 |
-
|
33 |
-
return response
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
with gr.Row():
|
43 |
-
topic_input = gr.Textbox(
|
44 |
-
label="Enter Topic", placeholder="e.g., Simulation Theory", lines=1
|
45 |
-
)
|
46 |
-
generate_button = gr.Button("Generate Article")
|
47 |
-
|
48 |
-
output_text = gr.Markdown(label="Generated Article")
|
49 |
-
|
50 |
-
generate_button.click(fn=generate_article, inputs=topic_input, outputs=output_text)
|
51 |
|
52 |
-
|
53 |
-
if __name__ == "__main__":
|
54 |
-
app.launch()
|
|
|
12 |
# Access the Groq API key
|
13 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
14 |
|
|
|
15 |
agent = Agent(
|
16 |
model=Groq(id="llama-3.3-70b-versatile", api_key=groq_api_key),
|
17 |
tools=[DuckDuckGo(), Newspaper4k()],
|
|
|
24 |
markdown=True,
|
25 |
show_tool_calls=True,
|
26 |
add_datetime_to_instructions=True,
|
27 |
+
# debug_mode=True,
|
28 |
)
|
29 |
|
|
|
30 |
def generate_article(topic):
|
31 |
+
return agent.print_response(topic, stream=True)
|
|
|
32 |
|
33 |
+
iface = gr.Interface(
|
34 |
+
fn=generate_article,
|
35 |
+
inputs="text",
|
36 |
+
outputs="text",
|
37 |
+
title="NYT Article Generator",
|
38 |
+
description="Enter a topic to generate an NYT-style article.",
|
39 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
iface.launch()
|
|
|
|