Spaces:
Sleeping
Sleeping
File size: 1,195 Bytes
93e917d 25191b2 93e917d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
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()
|