Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -462,7 +462,7 @@ WHATSAPP_EXTRACTION_PROMPT = """You are a support knowledge base curator for the
|
|
| 462 |
Your task: analyse this WhatsApp support group chat segment and extract ONLY clear problem→solution pairs.
|
| 463 |
|
| 464 |
CONTEXT ABOUT THIS APP:
|
| 465 |
-
- "Iris" is a
|
| 466 |
- Common issues: GPS location not detected, clock-in failures, app killed by Android battery optimiser,
|
| 467 |
teller passkey problems, hours not recording correctly, store radius too small, wrong teller name shown.
|
| 468 |
- Messages mix English, Shona, and Ndebele. Understand regional vernacular (e.g. "irikudzima" = switching off,
|
|
@@ -612,6 +612,7 @@ def whatsapp_import():
|
|
| 612 |
return jsonify({
|
| 613 |
"ok": True,
|
| 614 |
"articles_found": len(all_articles),
|
|
|
|
| 615 |
"saved": stats["saved"],
|
| 616 |
"skipped_dupes": stats["skipped"],
|
| 617 |
})
|
|
@@ -706,7 +707,8 @@ def bulk_upload():
|
|
| 706 |
return jsonify({"ok": False, "error": "No articles extracted from file"}), 400
|
| 707 |
|
| 708 |
stats = _save_kb_articles(articles, source_label=f"bulk_upload:{filename}")
|
| 709 |
-
return jsonify({"ok": True, "articles_found": len(articles), "
|
|
|
|
| 710 |
|
| 711 |
|
| 712 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
@@ -868,7 +870,9 @@ def tutorial_ingest():
|
|
| 868 |
elif not isinstance(val, int):
|
| 869 |
a[ts_key] = 0
|
| 870 |
stats = _save_kb_articles(articles, source_label=f"tutorial:{video_title}")
|
| 871 |
-
return jsonify({"ok": True, "video_title": video_title, "articles_found": len(articles),
|
|
|
|
|
|
|
| 872 |
|
| 873 |
|
| 874 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
@@ -903,7 +907,9 @@ def agent_solution_nl():
|
|
| 903 |
if ticket_id:
|
| 904 |
article.setdefault("tags", []).append(f"ticket:{ticket_id}")
|
| 905 |
stats = _save_kb_articles([article], source_label=f"agent:{agent_id}")
|
| 906 |
-
return jsonify({"ok": True, "saved": stats["saved"],
|
|
|
|
|
|
|
| 907 |
|
| 908 |
|
| 909 |
@app.post("/api/kb/agent-solution-voice")
|
|
@@ -925,7 +931,9 @@ def agent_solution_voice():
|
|
| 925 |
if ticket_id:
|
| 926 |
article.setdefault("tags", []).append(f"ticket:{ticket_id}")
|
| 927 |
stats = _save_kb_articles([article], source_label=f"agent:{agent_id}")
|
| 928 |
-
return jsonify({"ok": True, "transcript": transcript, "saved": stats["saved"],
|
|
|
|
|
|
|
| 929 |
|
| 930 |
|
| 931 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 462 |
Your task: analyse this WhatsApp support group chat segment and extract ONLY clear problem→solution pairs.
|
| 463 |
|
| 464 |
CONTEXT ABOUT THIS APP:
|
| 465 |
+
- "Iris" is a POS system and it also includes fiscalisation, mobile attendance/location tracking at retail stores.
|
| 466 |
- Common issues: GPS location not detected, clock-in failures, app killed by Android battery optimiser,
|
| 467 |
teller passkey problems, hours not recording correctly, store radius too small, wrong teller name shown.
|
| 468 |
- Messages mix English, Shona, and Ndebele. Understand regional vernacular (e.g. "irikudzima" = switching off,
|
|
|
|
| 612 |
return jsonify({
|
| 613 |
"ok": True,
|
| 614 |
"articles_found": len(all_articles),
|
| 615 |
+
"articles": all_articles, # full list — frontend INSERTs to Supabase kb_articles
|
| 616 |
"saved": stats["saved"],
|
| 617 |
"skipped_dupes": stats["skipped"],
|
| 618 |
})
|
|
|
|
| 707 |
return jsonify({"ok": False, "error": "No articles extracted from file"}), 400
|
| 708 |
|
| 709 |
stats = _save_kb_articles(articles, source_label=f"bulk_upload:{filename}")
|
| 710 |
+
return jsonify({"ok": True, "articles_found": len(articles), "articles": articles, # full list — frontend INSERTs to Supabase kb_articles
|
| 711 |
+
"saved": stats["saved"], "skipped_dupes": stats["skipped"]})
|
| 712 |
|
| 713 |
|
| 714 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 870 |
elif not isinstance(val, int):
|
| 871 |
a[ts_key] = 0
|
| 872 |
stats = _save_kb_articles(articles, source_label=f"tutorial:{video_title}")
|
| 873 |
+
return jsonify({"ok": True, "video_title": video_title, "articles_found": len(articles),
|
| 874 |
+
"articles": articles, # full list — frontend INSERTs to Supabase kb_articles
|
| 875 |
+
"saved": stats["saved"], "skipped_dupes": stats["skipped"]})
|
| 876 |
|
| 877 |
|
| 878 |
# ══════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 907 |
if ticket_id:
|
| 908 |
article.setdefault("tags", []).append(f"ticket:{ticket_id}")
|
| 909 |
stats = _save_kb_articles([article], source_label=f"agent:{agent_id}")
|
| 910 |
+
return jsonify({"ok": True, "saved": stats["saved"],
|
| 911 |
+
"article": article, # single article — frontend INSERTs to Supabase kb_articles
|
| 912 |
+
"articles": [article]})
|
| 913 |
|
| 914 |
|
| 915 |
@app.post("/api/kb/agent-solution-voice")
|
|
|
|
| 931 |
if ticket_id:
|
| 932 |
article.setdefault("tags", []).append(f"ticket:{ticket_id}")
|
| 933 |
stats = _save_kb_articles([article], source_label=f"agent:{agent_id}")
|
| 934 |
+
return jsonify({"ok": True, "transcript": transcript, "saved": stats["saved"],
|
| 935 |
+
"article": article, # single article — frontend INSERTs to Supabase kb_articles
|
| 936 |
+
"articles": [article]})
|
| 937 |
|
| 938 |
|
| 939 |
# ══════════════════════════════════════════════════════════════════════════════
|