Ngum commited on
Commit
dbbfc0c
·
1 Parent(s): 75fdf5e

Improve: Make responses more concise, reduce emoji spam, better prompts

Browse files
Files changed (3) hide show
  1. groq_fallback.py +13 -9
  2. main.py +10 -8
  3. prompt_engine/templates.py +9 -2
groq_fallback.py CHANGED
@@ -50,16 +50,20 @@ class GroqFallback:
50
 
51
  Your role:
52
  1. Answer questions about ALU accurately and professionally
53
- 2. For non-ALU questions, provide helpful general information
54
- 3. If you don't know something specific about ALU, admit it
55
- 4. Keep responses concise (2-3 paragraphs maximum)
56
- 5. Be friendly and professional
57
 
58
- Important:
59
- - ALU is a revolutionary university founded by Fred Swaniker in 2015
60
- - ALU has campuses in Kigali, Rwanda and Pamplemousses, Mauritius
61
- - ALU offers programs in Software Engineering, Entrepreneurial Leadership, and Global Challenges
62
- - Annual tuition is approximately $3,000 USD"""
 
 
 
 
63
 
64
  user_message = query
65
  if alu_context:
 
50
 
51
  Your role:
52
  1. Answer questions about ALU accurately and professionally
53
+ 2. For non-ALU questions, provide helpful, concise general information
54
+ 3. Keep responses brief (1-2 paragraphs for general knowledge, 2-3 for ALU topics)
55
+ 4. Be direct and friendly - avoid over-apologizing or being overly verbose
56
+ 5. Don't add "💡 Is there anything else..." endings - let the conversation flow naturally
57
 
58
+ Important ALU facts:
59
+ - Founded by Fred Swaniker in 2015
60
+ - Campuses in Kigali, Rwanda and Pamplemousses, Mauritius
61
+ - Programs: Software Engineering, Entrepreneurial Leadership, Global Challenges
62
+ - Annual tuition: ~$3,000 USD
63
+ - Website: https://www.alueducation.com
64
+
65
+ For links: Provide them directly without saying "I can't provide links"
66
+ For missing info: Be helpful and suggest where to find it, not apologetic"""
67
 
68
  user_message = query
69
  if alu_context:
main.py CHANGED
@@ -396,10 +396,11 @@ def process_chat_internal(request: ChatRequest):
396
  print(f"Error in conversational fallback: {e}")
397
  # Continue with original response if conversational fallback fails
398
 
399
- # Add a friendly sign-off to responses if they don't already have one
400
- friendly_endings = ["Feel free to ask", "Let me know", "Hope that helps", "Anything else", "Can I help"]
401
- if not any(ending in response for ending in friendly_endings) and len(response) > 100:
402
- response += "\n\n💡 Is there anything else about ALU you'd like to know?"
 
403
 
404
  # Add AI response to conversation memory
405
  conversation_memory.add_message(user_id, "assistant", response, conversation.id)
@@ -487,10 +488,11 @@ def process_chat_internal(request: ChatRequest):
487
  print(f"Error in conversational fallback: {e}")
488
  # Continue with original response if conversational fallback fails
489
 
490
- # Add a friendly sign-off to responses if they don't already have one
491
- friendly_endings = ["Feel free to ask", "Let me know", "Hope that helps", "Anything else", "Can I help"]
492
- if not any(ending in response for ending in friendly_endings) and len(response) > 100:
493
- response += "\n\n💡 Is there anything else about ALU you'd like to know?"
 
494
 
495
  # Add AI response to conversation memory
496
  conversation_memory.add_message(user_id, "assistant", response, conversation.id)
 
396
  print(f"Error in conversational fallback: {e}")
397
  # Continue with original response if conversational fallback fails
398
 
399
+ # Add a friendly sign-off only for very short responses or when appropriate
400
+ friendly_endings = ["Feel free to ask", "Let me know", "Hope that helps", "Anything else", "Can I help", "?"]
401
+ # Only add ending if response is very short AND doesn't already have a question mark
402
+ if len(response) < 80 and not any(ending in response for ending in friendly_endings):
403
+ response += "\n\nIs there anything else I can help you with?"
404
 
405
  # Add AI response to conversation memory
406
  conversation_memory.add_message(user_id, "assistant", response, conversation.id)
 
488
  print(f"Error in conversational fallback: {e}")
489
  # Continue with original response if conversational fallback fails
490
 
491
+ # Add a friendly sign-off only for very short responses
492
+ friendly_endings = ["Feel free to ask", "Let me know", "Hope that helps", "Anything else", "Can I help", "?"]
493
+ # Only add ending if response is very short AND doesn't already have a question mark
494
+ if len(response) < 80 and not any(ending in response for ending in friendly_endings):
495
+ response += "\n\nIs there anything else I can help you with?"
496
 
497
  # Add AI response to conversation memory
498
  conversation_memory.add_message(user_id, "assistant", response, conversation.id)
prompt_engine/templates.py CHANGED
@@ -12,7 +12,14 @@ PROMPTS_DIR.mkdir(exist_ok=True)
12
  # Default prompt templates for different situations
13
  DEFAULT_PROMPTS = {
14
  "general": """
15
- As an AI assistant for African Leadership University (ALU) students, I aim to provide helpful, accurate, and contextual responses.
 
 
 
 
 
 
 
16
 
17
  Context information:
18
  {context}
@@ -22,7 +29,7 @@ Chat history:
22
 
23
  User query: {query}
24
 
25
- Respond to the query using the context provided, and maintain a friendly and supportive tone.
26
  """,
27
  "academic": """
28
  As an academic assistant for ALU students, I provide educational guidance and help with coursework.
 
12
  # Default prompt templates for different situations
13
  DEFAULT_PROMPTS = {
14
  "general": """
15
+ You are an AI assistant for African Leadership University (ALU). Provide helpful, accurate, and concise responses.
16
+
17
+ Guidelines:
18
+ - Be direct and friendly - avoid over-apologizing or being verbose
19
+ - Keep responses brief (1-2 paragraphs unless more detail is needed)
20
+ - Don't say "Unfortunately, I don't have information" - instead be proactive and helpful
21
+ - Provide links directly when asked (e.g., https://www.alueducation.com)
22
+ - Don't add repetitive endings like "💡 Is there anything else..."
23
 
24
  Context information:
25
  {context}
 
29
 
30
  User query: {query}
31
 
32
+ Respond using the context provided with a friendly, professional tone.
33
  """,
34
  "academic": """
35
  As an academic assistant for ALU students, I provide educational guidance and help with coursework.