nikeshn commited on
Commit
370041e
·
verified ·
1 Parent(s): 4b6d98d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -125,7 +125,7 @@ def _fixed_social_answer(question: str) -> str | None:
125
  "answer library service questions, and guide you to the right librarian when needed."
126
  )
127
 
128
- if re.fullmatch(r"(what can you do|what do you do|how can you help|help|what help can you provide)", q):
129
  return (
130
  "I can help you search for articles and books, suggest databases, find full text, "
131
  "answer questions about library services, and connect you with the right Khalifa University Library staff member."
@@ -1357,17 +1357,12 @@ async def _answer_general(question: str, history=None) -> dict:
1357
  "Are you looking for one of these? You can also type your question directly."
1358
  )
1359
  return {"answer": guided, "sources": [], "model": "libbee-greeting"}
1360
-
1361
- fixed_social = _fixed_social_answer(question)
1362
- if fixed_social:
1363
- return {"answer": fixed_social, "sources": [], "model": "libbee-social-fixed"}
1364
-
1365
  try:
1366
  behavior = get_behavior_instructions()
1367
  llm = ChatOpenAI(model="gpt-4o-mini", temperature=0.4, max_tokens=220)
1368
  msgs = []
1369
  if behavior:
1370
- msgs.append({"role": "system", "content": behavior + "\nFor social, greeting, or self-description questions, answer as LibBee in a warm, brief, natural way. Make it clear that you are LibBee, the Khalifa University Library AI Assistant, and that you help with books, articles, databases, library services, research support, and staff contacts. For questions like 'how old are you', playful teasing, or mild mockery, respond politely and briefly, without sounding defensive. If the question is not library-related, you may gently mention that you are specialized in library help. Match the language of the user question."})
1371
  for m in (history or [])[-4:]:
1372
  if m.get("role") in ("user", "assistant"):
1373
  msgs.append({"role": m["role"], "content": m.get("content", "")})
 
125
  "answer library service questions, and guide you to the right librarian when needed."
126
  )
127
 
128
+ if re.fullmatch(r"(what can you do|what do you do|how can you help|what help can you provide)", q):
129
  return (
130
  "I can help you search for articles and books, suggest databases, find full text, "
131
  "answer questions about library services, and connect you with the right Khalifa University Library staff member."
 
1357
  "Are you looking for one of these? You can also type your question directly."
1358
  )
1359
  return {"answer": guided, "sources": [], "model": "libbee-greeting"}
 
 
 
 
 
1360
  try:
1361
  behavior = get_behavior_instructions()
1362
  llm = ChatOpenAI(model="gpt-4o-mini", temperature=0.4, max_tokens=220)
1363
  msgs = []
1364
  if behavior:
1365
+ msgs.append({"role": "system", "content": behavior + "\nFor social, greeting, or self-description questions, answer as LibBee in a warm, brief, natural way. Make it clear that you are LibBee, the Khalifa University Library AI Assistant, and that you help with books, articles, databases, library services, research support, and staff contacts. For questions like 'how are you', 'who are you', 'what are you', 'what can you do', 'are you a bot', playful teasing, or mild mockery, respond politely and briefly, without sounding defensive. If the question is not library-related, you may gently mention that you are specialized in library help. Match the language of the user question."})
1366
  for m in (history or [])[-4:]:
1367
  if m.get("role") in ("user", "assistant"):
1368
  msgs.append({"role": m["role"], "content": m.get("content", "")})