Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,25 @@
|
|
1 |
-
import gradio as gr
|
2 |
import os
|
|
|
3 |
from groq import Groq
|
4 |
|
5 |
# Initialize Groq client
|
6 |
-
client = Groq(
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
def generate_email(name, project, key_benefits):
|
11 |
-
prompt = f""
|
12 |
-
Write a professional email to {name} about the {project} project.
|
13 |
-
Highlight the following key benefits:
|
14 |
-
{key_benefits}
|
15 |
-
|
16 |
-
The email should be concise, engaging, and persuasive.
|
17 |
-
"""
|
18 |
|
19 |
chat_completion = client.chat.completions.create(
|
20 |
messages=[
|
21 |
-
{
|
22 |
-
|
23 |
-
"content": prompt,
|
24 |
-
}
|
25 |
],
|
26 |
-
model="mixtral-8x7b-32768",
|
27 |
-
temperature=0.
|
28 |
max_tokens=500,
|
29 |
)
|
30 |
|
@@ -34,14 +29,14 @@ def generate_email(name, project, key_benefits):
|
|
34 |
iface = gr.Interface(
|
35 |
fn=generate_email,
|
36 |
inputs=[
|
37 |
-
gr.Textbox(label="
|
38 |
gr.Textbox(label="Project Name"),
|
39 |
-
gr.Textbox(label="Key Benefits
|
40 |
],
|
41 |
outputs=gr.Textbox(label="Generated Email"),
|
42 |
-
title="
|
43 |
-
description="Generate personalized
|
44 |
)
|
45 |
|
46 |
-
# Launch the
|
47 |
iface.launch()
|
|
|
|
|
1 |
import os
|
2 |
+
import gradio as gr
|
3 |
from groq import Groq
|
4 |
|
5 |
# Initialize Groq client
|
6 |
+
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
7 |
+
|
8 |
+
# System prompt with recipient's profile
|
9 |
+
SYSTEM_PROMPT = """
|
10 |
+
You are an AI assistant that generates personalized emails. The recipient is John Doe, a 45-year-old marketing executive at a tech company. He is interested in innovative marketing strategies and has a busy schedule.
|
11 |
+
"""
|
12 |
|
13 |
def generate_email(name, project, key_benefits):
|
14 |
+
prompt = f"Generate an email to the person described in the system prompt. The email should be from {name}, about the project '{project}', and highlight the following key benefits: {key_benefits}"
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
chat_completion = client.chat.completions.create(
|
17 |
messages=[
|
18 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
19 |
+
{"role": "user", "content": prompt}
|
|
|
|
|
20 |
],
|
21 |
+
model="mixtral-8x7b-32768",
|
22 |
+
temperature=0.5,
|
23 |
max_tokens=500,
|
24 |
)
|
25 |
|
|
|
29 |
iface = gr.Interface(
|
30 |
fn=generate_email,
|
31 |
inputs=[
|
32 |
+
gr.Textbox(label="Your Name"),
|
33 |
gr.Textbox(label="Project Name"),
|
34 |
+
gr.Textbox(label="Key Benefits")
|
35 |
],
|
36 |
outputs=gr.Textbox(label="Generated Email"),
|
37 |
+
title="Email Generator",
|
38 |
+
description="Generate a personalized email based on the given inputs."
|
39 |
)
|
40 |
|
41 |
+
# Launch the app
|
42 |
iface.launch()
|