Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -784,6 +784,9 @@ async def chat_with_ai(input_data: ChatInput):
|
|
| 784 |
top_meta = (metadatas or [{}])[0] if metadatas else {}
|
| 785 |
msg_low = (input_data.user_message or "").lower()
|
| 786 |
|
|
|
|
|
|
|
|
|
|
| 787 |
# Query-based prereq nudge
|
| 788 |
PREREQ_TERMS = (
|
| 789 |
"pre req", "pre-requisite", "pre-requisites", "prerequisite",
|
|
@@ -907,7 +910,7 @@ async def chat_with_ai(input_data: ChatInput):
|
|
| 907 |
|
| 908 |
elif detected_intent == "errors":
|
| 909 |
full_errors = get_best_errors_section_text(best_doc)
|
| 910 |
-
assist_followup = None # collect a helpful follow-up for generic cases
|
| 911 |
|
| 912 |
if full_errors:
|
| 913 |
ctx_err = _extract_errors_only(full_errors, max_lines=30)
|
|
@@ -921,14 +924,14 @@ async def chat_with_ai(input_data: ChatInput):
|
|
| 921 |
if is_specific_error:
|
| 922 |
context = _filter_error_lines_by_query(ctx_err, input_data.user_message, max_lines=1)
|
| 923 |
else:
|
| 924 |
-
|
| 925 |
all_lines: List[str] = _normalize_lines(ctx_err)
|
| 926 |
error_bullets = [ln for ln in all_lines if re.match(r"^\s*[\-\*\u2022]\s*", ln) or (":" in ln)]
|
| 927 |
# limit to reasonable count (e.g., 8)
|
| 928 |
context = "\n".join(error_bullets[:8]).strip()
|
| 929 |
assist_followup = (
|
| 930 |
-
|
| 931 |
-
|
| 932 |
|
| 933 |
escalation_line = _extract_escalation_line(full_errors)
|
| 934 |
|
|
|
|
| 784 |
top_meta = (metadatas or [{}])[0] if metadatas else {}
|
| 785 |
msg_low = (input_data.user_message or "").lower()
|
| 786 |
|
| 787 |
+
GENERIC_ERROR_TERMS = ("error", "issue", "problem", "not working", "failed", "failure")
|
| 788 |
+
generic_error_signal = any(t in msg_low for t in GENERIC_ERROR_TERMS)
|
| 789 |
+
|
| 790 |
# Query-based prereq nudge
|
| 791 |
PREREQ_TERMS = (
|
| 792 |
"pre req", "pre-requisite", "pre-requisites", "prerequisite",
|
|
|
|
| 910 |
|
| 911 |
elif detected_intent == "errors":
|
| 912 |
full_errors = get_best_errors_section_text(best_doc)
|
| 913 |
+
#assist_followup = None # collect a helpful follow-up for generic cases
|
| 914 |
|
| 915 |
if full_errors:
|
| 916 |
ctx_err = _extract_errors_only(full_errors, max_lines=30)
|
|
|
|
| 924 |
if is_specific_error:
|
| 925 |
context = _filter_error_lines_by_query(ctx_err, input_data.user_message, max_lines=1)
|
| 926 |
else:
|
| 927 |
+
|
| 928 |
all_lines: List[str] = _normalize_lines(ctx_err)
|
| 929 |
error_bullets = [ln for ln in all_lines if re.match(r"^\s*[\-\*\u2022]\s*", ln) or (":" in ln)]
|
| 930 |
# limit to reasonable count (e.g., 8)
|
| 931 |
context = "\n".join(error_bullets[:8]).strip()
|
| 932 |
assist_followup = (
|
| 933 |
+
"Please tell me which error above matches your screen (paste the exact text), "
|
| 934 |
+
"or share a screenshot. I can guide you further or raise a ServiceNow ticket." )
|
| 935 |
|
| 936 |
escalation_line = _extract_escalation_line(full_errors)
|
| 937 |
|