my-email-bot / app.py
siddhartharya's picture
Update app.py
1051c7d verified
raw
history blame
1.2 kB
import gradio as gr
import os
from groq import Groq
# Initialize Groq client
client = Groq(
api_key=os.environ["GROQ_API_KEY"],
)
def generate_email(name, project, key_benefits):
prompt = f"""
Write a professional email to {name} about the {project} project.
Highlight the following key benefits:
{key_benefits}
The email should be concise, engaging, and persuasive.
"""
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="mixtral-8x7b-32768", # or another appropriate Groq model
temperature=0.7,
max_tokens=500,
)
return chat_completion.choices[0].message.content
# Create Gradio interface
iface = gr.Interface(
fn=generate_email,
inputs=[
gr.Textbox(label="Recipient Name"),
gr.Textbox(label="Project Name"),
gr.Textbox(label="Key Benefits (comma-separated)")
],
outputs=gr.Textbox(label="Generated Email"),
title="AI Email Generator",
description="Generate personalized emails using Groq LLM"
)
# Launch the interface
iface.launch()