Update app.py
Browse files
app.py
CHANGED
|
@@ -47,24 +47,39 @@ def contextual_pitch_assistant(csv_file, query):
|
|
| 47 |
D, I = index.search(q_emb, 3)
|
| 48 |
retrieved = [text_chunks[i] for i in I[0]]
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
prompt = f"""
|
| 51 |
You are an expert in B2B email sales and marketing for dental technology solutions.
|
| 52 |
|
| 53 |
-
Write a short, natural-sounding
|
|
|
|
| 54 |
Rules:
|
| 55 |
-
- Always begin with "Dear {
|
| 56 |
-
- Refer naturally to the clinic "{
|
| 57 |
-
- Focus on
|
| 58 |
-
-
|
| 59 |
-
- Keep it under 150 words
|
| 60 |
- Include a polite call to action at the end (e.g. suggesting a demo or short call).
|
| 61 |
-
-
|
|
|
|
| 62 |
Query:
|
| 63 |
{query}
|
|
|
|
| 64 |
CRM context (for your understanding, do not copy verbatim):
|
| 65 |
{'---'.join(retrieved)}
|
| 66 |
"""
|
| 67 |
|
|
|
|
| 68 |
response = client.chat.completions.create(
|
| 69 |
model="gpt-4o-mini",
|
| 70 |
messages=[{"role": "user", "content": prompt}],
|
|
|
|
| 47 |
D, I = index.search(q_emb, 3)
|
| 48 |
retrieved = [text_chunks[i] for i in I[0]]
|
| 49 |
|
| 50 |
+
# Extract name and clinic safely first (outside the f-string)
|
| 51 |
+
try:
|
| 52 |
+
account_manager = retrieved[0].split("Account Manager: ")[1].split("\n")[0].strip()
|
| 53 |
+
except Exception:
|
| 54 |
+
account_manager = "team"
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
account_name = retrieved[0].split("Clinic: ")[1].split("\n")[0].strip()
|
| 58 |
+
except Exception:
|
| 59 |
+
account_name = "your clinic"
|
| 60 |
+
|
| 61 |
prompt = f"""
|
| 62 |
You are an expert in B2B email sales and marketing for dental technology solutions.
|
| 63 |
|
| 64 |
+
Write a short, natural-sounding HTML sales email for a dental clinic.
|
| 65 |
+
|
| 66 |
Rules:
|
| 67 |
+
- Always begin with "Dear {account_manager}," as the greeting.
|
| 68 |
+
- Refer naturally to the clinic "{account_name}" in the body.
|
| 69 |
+
- Focus on value, benefits, and a helpful tone — avoid technical jargon or metrics like churn or satisfaction scores.
|
| 70 |
+
- Never include placeholders such as "Your Company Name" or "[Your Name]".
|
| 71 |
+
- Keep it under 150 words.
|
| 72 |
- Include a polite call to action at the end (e.g. suggesting a demo or short call).
|
| 73 |
+
- Return only HTML — no markdown, no code fences.
|
| 74 |
+
|
| 75 |
Query:
|
| 76 |
{query}
|
| 77 |
+
|
| 78 |
CRM context (for your understanding, do not copy verbatim):
|
| 79 |
{'---'.join(retrieved)}
|
| 80 |
"""
|
| 81 |
|
| 82 |
+
|
| 83 |
response = client.chat.completions.create(
|
| 84 |
model="gpt-4o-mini",
|
| 85 |
messages=[{"role": "user", "content": prompt}],
|