File size: 1,198 Bytes
970f795
1051c7d
 
970f795
1051c7d
 
 
 
970f795
1051c7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970f795
1051c7d
 
 
970f795
 
1051c7d
 
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
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()