Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from agent import
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
"platform": platform
|
| 8 |
-
}
|
| 9 |
-
final_state = graph.run(initial_state)
|
| 10 |
-
|
| 11 |
-
post = final_state.get("post", "No post generated")
|
| 12 |
-
engagement = final_state.get("engagement_score", "N/A")
|
| 13 |
-
tone = final_state.get("tone_score", "N/A")
|
| 14 |
-
clarity = final_state.get("clarity_score", "N/A")
|
| 15 |
-
images = "\n".join(final_state.get("image_url", [])) or "No images found"
|
| 16 |
-
|
| 17 |
-
return post, engagement, tone, clarity, images
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
-
gr.Markdown("# Social Media Post Generator
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
outputs=[output_post, output_engagement, output_tone, output_clarity, output_images])
|
| 34 |
-
|
| 35 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from agent import workflow
|
| 3 |
|
| 4 |
+
def generate(topic, platform):
|
| 5 |
+
post, engagement, tone, clarity = workflow(topic, platform)
|
| 6 |
+
return post, engagement, tone, clarity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
+
gr.Markdown("# Social Media Post Generator")
|
| 10 |
+
topic_input = gr.Textbox(label="Topic", placeholder="Enter topic here")
|
| 11 |
+
platform_input = gr.Textbox(label="Platform", placeholder="e.g., LinkedIn, Twitter")
|
| 12 |
+
generate_btn = gr.Button("Generate Post")
|
| 13 |
+
post_output = gr.Textbox(label="Generated Post", lines=8)
|
| 14 |
+
engagement_output = gr.Textbox(label="Engagement Score")
|
| 15 |
+
tone_output = gr.Textbox(label="Tone Score")
|
| 16 |
+
clarity_output = gr.Textbox(label="Clarity Score")
|
| 17 |
+
|
| 18 |
+
generate_btn.click(fn=generate, inputs=[topic_input, platform_input], outputs=[post_output, engagement_output, tone_output, clarity_output])
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch()
|
|
|
|
|
|
|
|
|