Update app.py
Browse files
app.py
CHANGED
|
@@ -1474,7 +1474,7 @@ async def agent_query(req: AgentRequest):
|
|
| 1474 |
history = [{"role": m.role, "content": m.content} for m in req.history] if req.history else []
|
| 1475 |
use_claude = req.model == "claude" and bool(os.environ.get("ANTHROPIC_API_KEY"))
|
| 1476 |
|
| 1477 |
-
# ---- Early greeting handling ----
|
| 1478 |
q_clean = question.strip()
|
| 1479 |
if PURE_GREETING_RE.match(q_clean):
|
| 1480 |
answer = (
|
|
@@ -1500,6 +1500,25 @@ async def agent_query(req: AgentRequest):
|
|
| 1500 |
"source_mode": "social",
|
| 1501 |
}
|
| 1502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1503 |
# ---- Staff direct matching (name first, then role semantics) ----
|
| 1504 |
staff_match = _match_staff_name(question)
|
| 1505 |
if staff_match:
|
|
|
|
| 1474 |
history = [{"role": m.role, "content": m.content} for m in req.history] if req.history else []
|
| 1475 |
use_claude = req.model == "claude" and bool(os.environ.get("ANTHROPIC_API_KEY"))
|
| 1476 |
|
| 1477 |
+
# ---- Early greeting / social handling ----
|
| 1478 |
q_clean = question.strip()
|
| 1479 |
if PURE_GREETING_RE.match(q_clean):
|
| 1480 |
answer = (
|
|
|
|
| 1500 |
"source_mode": "social",
|
| 1501 |
}
|
| 1502 |
|
| 1503 |
+
if _looks_social_or_greeting(q_clean):
|
| 1504 |
+
general = await _answer_general(question, history)
|
| 1505 |
+
elapsed = time.time() - start
|
| 1506 |
+
return {
|
| 1507 |
+
"answer": general.get("answer", ""),
|
| 1508 |
+
"intent": "social_greeting",
|
| 1509 |
+
"tools_used": ["general"],
|
| 1510 |
+
"search_results": [],
|
| 1511 |
+
"sources": general.get("sources", []),
|
| 1512 |
+
"model_used": req.model,
|
| 1513 |
+
"response_time": round(elapsed, 2),
|
| 1514 |
+
"corrected_query": question,
|
| 1515 |
+
"natural_query": question,
|
| 1516 |
+
"database_query": question,
|
| 1517 |
+
"original_question": question,
|
| 1518 |
+
"is_follow_up": False,
|
| 1519 |
+
"source_mode": "social",
|
| 1520 |
+
}
|
| 1521 |
+
|
| 1522 |
# ---- Staff direct matching (name first, then role semantics) ----
|
| 1523 |
staff_match = _match_staff_name(question)
|
| 1524 |
if staff_match:
|