Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1534,103 +1534,7 @@ def validate_ai_output(ai_output, proof_points):
|
|
| 1534 |
validated_output = f"{validated_output}\n\nMissing Data:\n" + "\n".join(corrections)
|
| 1535 |
|
| 1536 |
return validated_output
|
| 1537 |
-
|
| 1538 |
-
prompt_message = """
|
| 1539 |
-
**Role**
|
| 1540 |
-
You are an expert copywriter specializing in creating high-quality marketing content that integrates Top-Scoring Statements for Each Trust Bucket into various formats. You must include exactly 3 TrustBuilders® for each Trust Bucket and strictly ensure all TrustBuilders® are actively used in the generated content. Please make content longer especially sales conversation.
|
| 1541 |
-
---
|
| 1542 |
-
**Data Handling**
|
| 1543 |
-
- Retrieve `selected_dataset_ai` and compute `DATAFRAME_PROOF_POINT` using `compute_dataframe_proof_point()`.
|
| 1544 |
-
- Default Company Name: Volkswagen (unless specified otherwise).
|
| 1545 |
-
---
|
| 1546 |
-
**DATAFRAME_PROOF_POINT Structure**
|
| 1547 |
-
- Trust Buckets: Stability, Development, Relationship, Benefit, Vision, Competence.
|
| 1548 |
-
- TrustBuilders®: Statements with percentages.
|
| 1549 |
-
---
|
| 1550 |
-
**Response Guidelines**
|
| 1551 |
-
1. If `DATAFRAME_PROOF_POINT` is empty:
|
| 1552 |
-
- Respond: "Trust Builder information is not provided. Generating content based on general knowledge."
|
| 1553 |
-
- Create content using general knowledge.
|
| 1554 |
-
2. **Listing Top-Scoring Statements**
|
| 1555 |
-
- For each of the six Trust Buckets, list exactly **3 TrustBuilders®**, irrespective of percentages.
|
| 1556 |
-
- If fewer than 3 TrustBuilders® are available for a bucket, repeat the highest-scoring TrustBuilders® until there are 3.
|
| 1557 |
-
- Use the following format to display top-scoring statements:
|
| 1558 |
-
Top-scoring statements
|
| 1559 |
-
**Bucket Name**
|
| 1560 |
-
- TrustBuilder® Statement 1 [Percentage]
|
| 1561 |
-
- TrustBuilder® Statement 2 [Percentage]
|
| 1562 |
-
- TrustBuilder® Statement 3 [Percentage]
|
| 1563 |
-
```
|
| 1564 |
-
3. If `DATAFRAME_PROOF_POINT` is present:
|
| 1565 |
-
- Display Top-Scoring Statements:
|
| 1566 |
-
- List the top three TrustBuilders® for each of the six Trust Buckets in the format:
|
| 1567 |
-
**Bucket Name**
|
| 1568 |
-
- Statement 1 [Percentage]
|
| 1569 |
-
- Statement 2 [Percentage]
|
| 1570 |
-
- Statement 3 [Percentage]
|
| 1571 |
-
**2. Generating Content**
|
| 1572 |
-
- Integrate **all listed TrustBuilders®** into the requested content format. Strictly minimu 9 trustbuilders must be used to make content longer.
|
| 1573 |
-
- Do not omit any TrustBuilders®—all must be actively and explicitly included in the content.
|
| 1574 |
-
- Maintain a **longer and detailed response**, using all the provided Trust statements to ensure comprehensive coverage.
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
**Strict Requirements**
|
| 1578 |
-
1. **Top-Scoring Statements for Each Trust Bucket:**
|
| 1579 |
-
- Exactly **3 TrustBuilders®** must be listed for each Trust Bucket, even if percentages are below 18%.
|
| 1580 |
-
- Ensure consistency in the format.
|
| 1581 |
-
**Content Guidelines**
|
| 1582 |
-
Use **all TrustBuilders®** in the content and make it longer.
|
| 1583 |
-
**General Rules**
|
| 1584 |
-
- Tone: Active, engaging, and professional. Avoid flowery or overly complex language.
|
| 1585 |
-
- Specificity: Include relevant names, numbers (e.g., dollars, years), programs, awards, strategies, or locations.
|
| 1586 |
-
---
|
| 1587 |
-
**Content Types**
|
| 1588 |
-
1. **Annual Reports/Articles**
|
| 1589 |
-
- Structure:
|
| 1590 |
-
- Headline
|
| 1591 |
-
- Main content (3-4 detailed paragraphs integrating all required TrustBuilders®).
|
| 1592 |
-
- Additional Sections:
|
| 1593 |
-
- List of TrustBuilders® Used : list minimum 9 top scoring statements retrieved
|
| 1594 |
-
- Heuristics Used: List 3-5 relevant heuristics.
|
| 1595 |
-
- Creative Techniques Used: Mention and explain any metaphor, analogy, or creative technique employed.
|
| 1596 |
-
2. **Sales Conversations/Ad Copy**
|
| 1597 |
-
-
|
| 1598 |
-
- Structure:
|
| 1599 |
-
Detailed conversation.
|
| 1600 |
-
- Intro line: "Here is a draft of your [Sales Conversation/Ad Copy]. Feel free to suggest further refinements."
|
| 1601 |
-
- Content structured using top scoring statements retrieved with clear messaging, integrating all required TrustBuilders®.
|
| 1602 |
-
- Additional Sections:
|
| 1603 |
-
- List of TrustBuilders® Used : list retreived trust statements 9 from top scoring.
|
| 1604 |
-
- Heuristics Used: List 3-5 relevant heuristics.
|
| 1605 |
-
- Creative Techniques Used: Mention and explain any creative elements used.
|
| 1606 |
-
3. **Emails, Newsletters, Direct Marketing Letters**
|
| 1607 |
-
- Intro Line: "Here is a draft of your [Email/Newsletter/Letter]. Feel free to suggest further refinements."
|
| 1608 |
-
- Content: Concise, actionable messaging with a call to action, integrating all required TrustBuilders®.
|
| 1609 |
-
- Additional Sections:
|
| 1610 |
-
- List of TrustBuilders® Used : list minimum 9 top scoring statements retrieved
|
| 1611 |
-
- Heuristics Used: List 3-5 relevant heuristics.
|
| 1612 |
-
- Creative Techniques Used: Highlight creative approaches used.
|
| 1613 |
-
---
|
| 1614 |
-
**Formatting Example**
|
| 1615 |
-
Top scoring statements
|
| 1616 |
-
**Stability**
|
| 1617 |
-
- High-quality manufacturing [25%]
|
| 1618 |
-
- Consistent reliability [22%]
|
| 1619 |
-
- Durable materials [19%]
|
| 1620 |
-
**Development**
|
| 1621 |
-
- Future-proof technology [30%]
|
| 1622 |
-
- Innovation in design [25%]
|
| 1623 |
-
- Commitment to sustainability [20%]
|
| 1624 |
-
**Relationship**
|
| 1625 |
-
- Long-term partnerships [27%]
|
| 1626 |
-
- Customer-first policies [22%]
|
| 1627 |
-
- Community engagement [19%]
|
| 1628 |
-
#### **GENERAL QUERIES**
|
| 1629 |
-
- For blogs or reports, refer to the knowledge base first. Focus on overall flow and structure without mentioning trust metrics unless requested.
|
| 1630 |
-
|
| 1631 |
-
|
| 1632 |
-
"""
|
| 1633 |
-
|
| 1634 |
|
| 1635 |
|
| 1636 |
prompt_template = ChatPromptTemplate.from_messages(
|
|
@@ -1754,25 +1658,15 @@ def chatbot_response(message, history):
|
|
| 1754 |
global df_builder_pivot_str
|
| 1755 |
|
| 1756 |
try:
|
| 1757 |
-
|
| 1758 |
-
output = agent_executor.invoke({"input": message, "chat_history": history})
|
| 1759 |
-
trust_tip, suggestion = get_trust_tip_and_suggestion()
|
| 1760 |
-
|
| 1761 |
-
# Prepend the selected dataset to the response
|
| 1762 |
-
response = f"**Selected Dataset: {selected_dataset_ai}**\n\n"
|
| 1763 |
|
| 1764 |
-
|
| 1765 |
-
|
| 1766 |
-
buckets_to_include = ["Development", "Benefit", "Vision"]
|
| 1767 |
-
else:
|
| 1768 |
-
# Include only Stability, Relationship, Benefit for VW Prospects
|
| 1769 |
-
buckets_to_include = ["Stability", "Relationship", "Benefit"]
|
| 1770 |
|
| 1771 |
-
|
| 1772 |
-
|
| 1773 |
-
response
|
| 1774 |
|
| 1775 |
-
response += output["output"]
|
| 1776 |
|
| 1777 |
# Add Trust Tip and Suggestion if not already in history
|
| 1778 |
if not any(f"**Trust Tip**: {trust_tip}" in entry["bot"] and f"**Suggestion**: {suggestion}" in entry["bot"] for entry in history):
|
|
|
|
| 1534 |
validated_output = f"{validated_output}\n\nMissing Data:\n" + "\n".join(corrections)
|
| 1535 |
|
| 1536 |
return validated_output
|
| 1537 |
+
c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1538 |
|
| 1539 |
|
| 1540 |
prompt_template = ChatPromptTemplate.from_messages(
|
|
|
|
| 1658 |
global df_builder_pivot_str
|
| 1659 |
|
| 1660 |
try:
|
| 1661 |
+
selected_dataset_ai = read_ai_dataset_selection()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1662 |
|
| 1663 |
+
# Recompute DATAFRAME_PROOF_POINT based on the selected dataset
|
| 1664 |
+
df_builder_pivot_str = compute_dataframe_proof_point()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1665 |
|
| 1666 |
+
output = agent_executor.invoke({"input": message, "chat_history": chat_history})
|
| 1667 |
+
trust_tip, suggestion = get_trust_tip_and_suggestion()
|
| 1668 |
+
response = f"**Selected Dataset: {selected_dataset_ai}**\n\n{output['output']} if selected dataset is vw customers display top scoring statments of these bucktes development , benefit and vision.Remanining should be included only when vwprospect dataset is selected"
|
| 1669 |
|
|
|
|
| 1670 |
|
| 1671 |
# Add Trust Tip and Suggestion if not already in history
|
| 1672 |
if not any(f"**Trust Tip**: {trust_tip}" in entry["bot"] and f"**Suggestion**: {suggestion}" in entry["bot"] for entry in history):
|