nikeshn commited on
Commit
5fac46b
·
verified ·
1 Parent(s): 23c9744

Update src/api/agent.py

Browse files
Files changed (1) hide show
  1. src/api/agent.py +36 -4
src/api/agent.py CHANGED
@@ -1218,8 +1218,14 @@ async def _rag_answer(question: str, rag_results: List[dict], history: List[Chat
1218
  "You are LibBee, the Khalifa University Library AI Assistant. "
1219
  "Answer the user's question using ONLY the context provided below. "
1220
  "Be concise, friendly, and use HTML <br> for line breaks where needed. "
1221
- f"If the context does not contain enough information, say so and suggest Ask a Librarian at {ASK_LIBRARIAN_URL}. "
1222
- "Never invent facts or URLs.\n\n"
 
 
 
 
 
 
1223
  f"CONTEXT:\n{context}\n\n"
1224
  + _GUARDRAIL
1225
  )
@@ -1253,6 +1259,16 @@ async def _llm_general_answer(question: str, history: List[ChatMessage], model:
1253
  "You are LibBee, the Khalifa University Library AI Assistant (Abu Dhabi, UAE). "
1254
  "Answer factually and concisely in 3-5 sentences. Use HTML <br> for line breaks. "
1255
  "KU means Khalifa University. If the topic is academic, briefly offer to help find library resources. "
 
 
 
 
 
 
 
 
 
 
1256
  + _GUARDRAIL
1257
  )
1258
  _cfg = _get_runtime_config()
@@ -2380,9 +2396,25 @@ def _find_staff_by_token(token: str) -> Optional[dict]:
2380
 
2381
  def _contact_footer_for_query(question: str, context: Optional[SearchContextPayload]) -> str:
2382
  q = (question or "").lower()
2383
- # FIX: removed broken default to _find_staff_by_token("muna") — Muna is not in STAFF_DIRECTORY
2384
  specialist: Optional[dict] = None
2385
- if any(t in q for t in ["database access", "proxy", "full text", "eresource", "e-resource", "remote access", "access problem"]):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2386
  specialist = _find_staff_by_token("rani")
2387
  elif any(t in q for t in ["website", "system", "technical", "login issue", "page not loading"]):
2388
  specialist = _find_staff_by_token("walter")
 
1218
  "You are LibBee, the Khalifa University Library AI Assistant. "
1219
  "Answer the user's question using ONLY the context provided below. "
1220
  "Be concise, friendly, and use HTML <br> for line breaks where needed. "
1221
+ "IMPORTANT — LINKS: When the context contains a URL (starting with https:// or http://), "
1222
+ "include it as a clickable HTML link using <a href=\"URL\" target=\"_blank\">link text</a>. "
1223
+ "For example, if context mentions 'library.ku.ac.ae/ill/' include it as a link. "
1224
+ "NEVER invent or guess URLs that do not appear in the context. "
1225
+ "Only link to URLs that are explicitly present in the context below. "
1226
+ f"If the context does not contain enough information, say so and suggest Ask a Librarian at "
1227
+ f'<a href="{ASK_LIBRARIAN_URL}" target="_blank">Ask a Librarian</a> or '
1228
+ f'<a href="mailto:libse@ku.ac.ae">libse@ku.ac.ae</a>.\n\n'
1229
  f"CONTEXT:\n{context}\n\n"
1230
  + _GUARDRAIL
1231
  )
 
1259
  "You are LibBee, the Khalifa University Library AI Assistant (Abu Dhabi, UAE). "
1260
  "Answer factually and concisely in 3-5 sentences. Use HTML <br> for line breaks. "
1261
  "KU means Khalifa University. If the topic is academic, briefly offer to help find library resources. "
1262
+ "When referencing KU Library services, include these verified links where relevant: "
1263
+ "Library homepage: https://library.ku.ac.ae | "
1264
+ "Ask a Librarian: https://library.ku.ac.ae/AskUs | "
1265
+ "Library hours: https://library.ku.ac.ae/hours | "
1266
+ "ILL requests: https://library.ku.ac.ae/ill/ | "
1267
+ "Study rooms: https://library.ku.ac.ae/rooms/ | "
1268
+ "E-resources: https://library.ku.ac.ae/eresources | "
1269
+ "Khazna repository: https://khazna.ku.ac.ae | "
1270
+ "PRIMO discovery: https://khalifa.primo.exlibrisgroup.com/discovery/search?vid=971KUOSTAR_INST:KU. "
1271
+ "Only use these exact URLs — never invent others. "
1272
  + _GUARDRAIL
1273
  )
1274
  _cfg = _get_runtime_config()
 
2396
 
2397
  def _contact_footer_for_query(question: str, context: Optional[SearchContextPayload]) -> str:
2398
  q = (question or "").lower()
 
2399
  specialist: Optional[dict] = None
2400
+
2401
+ # ILL — always Suaad Al Jneibi, not Jason
2402
+ if any(t in q for t in ["interlibrary", "ill request", "ill form", "borrow from another",
2403
+ "request article", "request a book", "not available at ku",
2404
+ "not in ku library", "inter library", "inter-library"]):
2405
+ # Use hardcoded ILL contact since Suaad may not be in staff directory
2406
+ footer = (
2407
+ "<br><br><strong>Library contact points</strong><br>"
2408
+ f'General help: <a href="{ASK_LIBRARIAN_URL}" target="_blank">Ask a Librarian</a> · '
2409
+ '<a href="mailto:libse@ku.ac.ae">libse@ku.ac.ae</a><br>'
2410
+ 'ILL requests: <a href="mailto:ill@ku.ac.ae">ill@ku.ac.ae</a> · '
2411
+ '<strong>Suaad Al Jneibi</strong> · '
2412
+ '<a href="mailto:suaad.aljneibi@ku.ac.ae">suaad.aljneibi@ku.ac.ae</a> · '
2413
+ '<a href="tel:+97123124278">+971 2 312 4278</a>'
2414
+ )
2415
+ return footer
2416
+ elif any(t in q for t in ["database access", "proxy", "full text", "eresource",
2417
+ "e-resource", "remote access", "access problem", "off campus"]):
2418
  specialist = _find_staff_by_token("rani")
2419
  elif any(t in q for t in ["website", "system", "technical", "login issue", "page not loading"]):
2420
  specialist = _find_staff_by_token("walter")