greetings / app.py
vishal1278's picture
removed hero image
25191b2
raw
history blame
1.2 kB
import sys
from PIL import Image
sys.path.append(".")
from utils import (
generate_dummy_data,
generate_summary,
generate_welcome_message,
)
from prompts import CAMPAIGN_DESCR
import gradio as gr
df = generate_dummy_data()
print(df)
campaign_names = list(CAMPAIGN_DESCR.keys())
def process_customer_selection(customer_name, campaign_name):
customer_data = df[df["Name"] == customer_name].iloc[0]
print(customer_data)
summary = generate_summary(customer_data)
message = generate_welcome_message(summary, campaign_name)
return summary, message
def create_gradio_app():
customer_names = df["Name"].tolist()
interface = gr.Interface(
fn=process_customer_selection,
inputs=[
gr.Dropdown(choices=customer_names, label="Select a Customer"),
gr.Dropdown(choices=campaign_names, label="Select a Campaign"),
],
outputs=[
gr.Textbox(label="Customer Summary [Input]"),
gr.Textbox(label="Personalized Welcome Message [Output]"),
],
title="Personalized Email Content Generator",
)
interface.launch(share=True)
# Run the Gradio app
create_gradio_app()