uumerrr684 commited on
Commit
f310d7e
Β·
verified Β·
1 Parent(s): 71b0c15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +90 -8
app.py CHANGED
@@ -69,6 +69,34 @@ st.markdown("""
69
  color: #ffffff !important;
70
  }
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  /* Chat history styling */
73
  .chat-history-item {
74
  padding: 8px 12px;
@@ -116,6 +144,31 @@ HISTORY_FILE = "rag_chat_history.json"
116
  SESSIONS_FILE = "rag_chat_sessions.json"
117
  USERS_FILE = "online_users.json"
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  # ================= GITHUB INTEGRATION =================
120
 
121
  def clone_github_repo():
@@ -508,12 +561,9 @@ class ProductionRAGSystem:
508
  # Create focused prompt for rich, engaging family responses
509
  if unlimited_tokens:
510
  prompt = f"""You are a warm, caring family assistant who knows everyone well. Based on the family information below, provide a rich, detailed, and engaging response.
511
-
512
  Family Document Context:
513
  {context}
514
-
515
  Question: {query}
516
-
517
  Instructions:
518
  - Use the document information as your foundation
519
  - Expand with logical personality traits and qualities someone like this would have
@@ -525,16 +575,13 @@ Instructions:
525
  - Include both strengths and endearing qualities
526
  - Keep it warm but informative (4-6 sentences total)
527
  - Sprinkle emojis naturally throughout, not just at the end
528
-
529
  Remember: You're helping someone learn about their family members in a meaningful way! πŸ’"""
530
  max_tokens = 400 # Increased for richer responses
531
  temperature = 0.3 # Slightly more creative
532
  else:
533
  # Shorter but still enhanced prompt for conservative mode
534
  prompt = f"""Based on this family info: {extracted_answer}
535
-
536
  Question: {query}
537
-
538
  Give a warm, detailed answer with 3-4 emojis spread throughout. Add 2-3 more qualities this person likely has. Make it caring and personal! πŸ’"""
539
  max_tokens = 150 # Better than 50 for family context
540
  temperature = 0.2
@@ -605,9 +652,7 @@ def get_general_ai_response(query, unlimited_tokens=False):
605
  max_tokens = 350 # Good limit for detailed family responses
606
  temperature = 0.5
607
  prompt = f"""You are a caring family assistant. Someone is asking about their family but I couldn't find specific information in their family documents.
608
-
609
  Question: {query}
610
-
611
  Please provide a warm, helpful response that:
612
  - Acknowledges I don't have specific information about their family member
613
  - Suggests they might want to add more details to their family profiles
@@ -749,6 +794,43 @@ with st.sidebar:
749
 
750
  st.divider()
751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
  # GitHub Integration
753
  st.header("πŸ™ GitHub Integration")
754
 
 
69
  color: #ffffff !important;
70
  }
71
 
72
+ /* Personality Questions Styling */
73
+ .personality-question {
74
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
75
+ color: white;
76
+ padding: 8px 12px;
77
+ margin: 4px 0;
78
+ border-radius: 8px;
79
+ border: none;
80
+ cursor: pointer;
81
+ transition: all 0.3s ease;
82
+ font-size: 0.85em;
83
+ width: 100%;
84
+ text-align: left;
85
+ }
86
+
87
+ .personality-question:hover {
88
+ transform: translateY(-2px);
89
+ box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
90
+ }
91
+
92
+ .personality-section {
93
+ background: #f8f9ff;
94
+ padding: 12px;
95
+ border-radius: 8px;
96
+ border-left: 4px solid #667eea;
97
+ margin: 10px 0;
98
+ }
99
+
100
  /* Chat history styling */
101
  .chat-history-item {
102
  padding: 8px 12px;
 
144
  SESSIONS_FILE = "rag_chat_sessions.json"
145
  USERS_FILE = "online_users.json"
146
 
147
+ # ================= PERSONALITY QUESTIONS =================
148
+
149
+ PERSONALITY_QUESTIONS = [
150
+ "What do you know about [name]?",
151
+ "How would you describe [name]'s personality?",
152
+ "Is [name] introvert or extrovert?",
153
+ "What do you think are [name]'s strengths?",
154
+ "Does [name] have any weaknesses?",
155
+ "What advice would you give [name]?",
156
+ "What is something you admire about [name]?",
157
+ "Do you remember anything about [name]'s friends or ambitions?",
158
+ "What words describe [name] best?"
159
+ ]
160
+
161
+ def insert_personality_question(question, name):
162
+ """Insert a personality question into the chat"""
163
+ formatted_question = question.replace("[name]", name)
164
+
165
+ # Add to chat
166
+ user_message = {"role": "user", "content": formatted_question}
167
+ st.session_state.messages.append(user_message)
168
+
169
+ # Trigger rerun to process the question
170
+ st.rerun()
171
+
172
  # ================= GITHUB INTEGRATION =================
173
 
174
  def clone_github_repo():
 
561
  # Create focused prompt for rich, engaging family responses
562
  if unlimited_tokens:
563
  prompt = f"""You are a warm, caring family assistant who knows everyone well. Based on the family information below, provide a rich, detailed, and engaging response.
 
564
  Family Document Context:
565
  {context}
 
566
  Question: {query}
 
567
  Instructions:
568
  - Use the document information as your foundation
569
  - Expand with logical personality traits and qualities someone like this would have
 
575
  - Include both strengths and endearing qualities
576
  - Keep it warm but informative (4-6 sentences total)
577
  - Sprinkle emojis naturally throughout, not just at the end
 
578
  Remember: You're helping someone learn about their family members in a meaningful way! πŸ’"""
579
  max_tokens = 400 # Increased for richer responses
580
  temperature = 0.3 # Slightly more creative
581
  else:
582
  # Shorter but still enhanced prompt for conservative mode
583
  prompt = f"""Based on this family info: {extracted_answer}
 
584
  Question: {query}
 
585
  Give a warm, detailed answer with 3-4 emojis spread throughout. Add 2-3 more qualities this person likely has. Make it caring and personal! πŸ’"""
586
  max_tokens = 150 # Better than 50 for family context
587
  temperature = 0.2
 
652
  max_tokens = 350 # Good limit for detailed family responses
653
  temperature = 0.5
654
  prompt = f"""You are a caring family assistant. Someone is asking about their family but I couldn't find specific information in their family documents.
 
655
  Question: {query}
 
656
  Please provide a warm, helpful response that:
657
  - Acknowledges I don't have specific information about their family member
658
  - Suggests they might want to add more details to their family profiles
 
794
 
795
  st.divider()
796
 
797
+ # Personality Questions Section
798
+ st.header("🎭 Personality Questions")
799
+
800
+ # Name input for personalizing questions
801
+ name_input = st.text_input("Enter name for personalized questions:", placeholder="e.g., Sarah, Ahmed", help="Replace [name] in questions with this name")
802
+
803
+ if name_input.strip():
804
+ name = name_input.strip()
805
+ st.markdown(f"""
806
+ <div class="personality-section">
807
+ <strong>πŸ’« Quick Questions for {name}:</strong><br>
808
+ <small>Click any question to ask about {name}</small>
809
+ </div>
810
+ """, unsafe_allow_html=True)
811
+
812
+ # Display personality questions as clickable buttons
813
+ for i, question in enumerate(PERSONALITY_QUESTIONS):
814
+ formatted_question = question.replace("[name]", name)
815
+ if st.button(formatted_question, key=f"pq_{i}", use_container_width=True):
816
+ # Add the question to chat
817
+ user_message = {"role": "user", "content": formatted_question}
818
+ st.session_state.messages.append(user_message)
819
+ st.rerun()
820
+ else:
821
+ st.markdown("""
822
+ <div class="personality-section">
823
+ <strong>πŸ’« Sample Questions:</strong><br>
824
+ <small>Enter a name above to personalize these questions</small>
825
+ </div>
826
+ """, unsafe_allow_html=True)
827
+
828
+ # Show sample questions without names
829
+ for question in PERSONALITY_QUESTIONS[:5]: # Show first 5 as examples
830
+ st.markdown(f"β€’ {question}")
831
+
832
+ st.divider()
833
+
834
  # GitHub Integration
835
  st.header("πŸ™ GitHub Integration")
836