mubashirhussaindev commited on
Commit
3458512
·
verified ·
1 Parent(s): 61b1afa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -31
app.py CHANGED
@@ -1,35 +1,21 @@
1
  import gradio as gr
2
- from agent import graph, State
3
 
4
- def generate_post(topic, platform):
5
- initial_state: State = {
6
- "topic": topic,
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 for B2B Banking")
21
-
22
- topic = gr.Textbox(label="Topic", value="digital transformation in banking")
23
- platform = gr.Dropdown(choices=["LinkedIn", "Twitter", "Facebook"], value="LinkedIn", label="Platform")
24
-
25
- btn = gr.Button("Generate Post")
26
- output_post = gr.Textbox(label="Generated Post", lines=10)
27
- output_engagement = gr.Textbox(label="Engagement Score")
28
- output_tone = gr.Textbox(label="Tone Score")
29
- output_clarity = gr.Textbox(label="Clarity Score")
30
- output_images = gr.Textbox(label="Image URLs")
31
-
32
- btn.click(generate_post, inputs=[topic, platform],
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()