Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -652,15 +652,13 @@ def get_emotion_based_system_message(emotional_tone: str, intent_category: str)
|
|
| 652 |
tone_guideline = tone_guidelines.get(emotional_tone, tone_guidelines["neutral"])
|
| 653 |
intent_guideline = intent_guidelines.get(intent_category, intent_guidelines["general"])
|
| 654 |
|
| 655 |
-
system_message = f"""You are GAKR AI,
|
| 656 |
|
| 657 |
-
|
| 658 |
-
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
- User intent category: {intent_category.upper()}
|
| 663 |
-
{intent_guideline}
|
| 664 |
|
| 665 |
CORE PRINCIPLES:
|
| 666 |
1. Adapt your tone to match the user's emotional state
|
|
@@ -669,7 +667,13 @@ CORE PRINCIPLES:
|
|
| 669 |
4. Use appropriate formatting for clarity
|
| 670 |
5. Acknowledge limitations when uncertain
|
| 671 |
|
| 672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
|
| 674 |
return system_message
|
| 675 |
|
|
@@ -785,10 +789,20 @@ async def generate_reply_stream(
|
|
| 785 |
|
| 786 |
# Format according to Phi-3.5 chat template with emotional intelligence
|
| 787 |
chat_template = f"""<|system|>
|
| 788 |
-
{system_message}
|
|
|
|
|
|
|
| 789 |
<|user|>
|
| 790 |
USER QUERY: {prompt}
|
| 791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
CONTEXTUAL ANALYSIS:
|
| 793 |
{context}
|
| 794 |
|
|
@@ -796,9 +810,7 @@ Please provide a response that:
|
|
| 796 |
1. Addresses the specific intent ({intent_info['intent_label']})
|
| 797 |
2. Appropriately responds to the emotional tone ({emotion_info['emotional_tone']})
|
| 798 |
3. Incorporates relevant information from the context
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
Your response should be emotionally intelligent and intent-aware.<|end|>
|
| 802 |
<|assistant|>
|
| 803 |
"""
|
| 804 |
|
|
|
|
| 652 |
tone_guideline = tone_guidelines.get(emotional_tone, tone_guidelines["neutral"])
|
| 653 |
intent_guideline = intent_guidelines.get(intent_category, intent_guidelines["general"])
|
| 654 |
|
| 655 |
+
system_message = f"""You are GAKR AI, a helpful and knowledgeable assistant.
|
| 656 |
|
| 657 |
+
RESPONSE APPROACH:
|
| 658 |
+
- Start with the most direct answer
|
| 659 |
+
- Provide supporting details when helpful
|
| 660 |
+
- Use simple formatting (bullets, bold) for clarity
|
| 661 |
+
- Be accurate and acknowledge uncertainty
|
|
|
|
|
|
|
| 662 |
|
| 663 |
CORE PRINCIPLES:
|
| 664 |
1. Adapt your tone to match the user's emotional state
|
|
|
|
| 667 |
4. Use appropriate formatting for clarity
|
| 668 |
5. Acknowledge limitations when uncertain
|
| 669 |
|
| 670 |
+
COMMUNICATION STYLE:
|
| 671 |
+
- Clear and concise
|
| 672 |
+
- Adapt to question complexity
|
| 673 |
+
- Focus on practical usefulness
|
| 674 |
+
- Avoid unnecessary repetition
|
| 675 |
+
|
| 676 |
+
Your goal: Provide the most helpful response possible."""
|
| 677 |
|
| 678 |
return system_message
|
| 679 |
|
|
|
|
| 789 |
|
| 790 |
# Format according to Phi-3.5 chat template with emotional intelligence
|
| 791 |
chat_template = f"""<|system|>
|
| 792 |
+
{system_message}
|
| 793 |
+
IMPORTANT: You must stay in character as GAKR AI at all times.
|
| 794 |
+
<|end|>
|
| 795 |
<|user|>
|
| 796 |
USER QUERY: {prompt}
|
| 797 |
|
| 798 |
+
EMOTIONAL CONTEXT:
|
| 799 |
+
- Tone guideline: {tone_guideline}
|
| 800 |
+
- Detected user emotional tone: {emotional_tone.upper()}
|
| 801 |
+
|
| 802 |
+
INTENT CONTEXT:
|
| 803 |
+
- Intent guideline: {intent_guideline}
|
| 804 |
+
- Detected User intent category: {intent_category.upper()}
|
| 805 |
+
|
| 806 |
CONTEXTUAL ANALYSIS:
|
| 807 |
{context}
|
| 808 |
|
|
|
|
| 810 |
1. Addresses the specific intent ({intent_info['intent_label']})
|
| 811 |
2. Appropriately responds to the emotional tone ({emotion_info['emotional_tone']})
|
| 812 |
3. Incorporates relevant information from the context
|
| 813 |
+
Your goal: Provide the most helpful response possible. <|end|>
|
|
|
|
|
|
|
| 814 |
<|assistant|>
|
| 815 |
"""
|
| 816 |
|