Spaces:
Runtime error
Runtime error
Update task_processing.py
Browse files- task_processing.py +79 -44
task_processing.py
CHANGED
|
@@ -1,48 +1,83 @@
|
|
| 1 |
-
# task_processing.py (
|
| 2 |
-
#
|
| 3 |
-
#
|
| 4 |
-
#
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
return
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# task_processing.py (Updated for new VerdictAI modes)
|
| 2 |
+
# - Adds labels/headers for new modes introduced in app.py
|
| 3 |
+
# - Keeps lightweight, post-processing-only behavior
|
| 4 |
+
# - No redundant model calls (no extra Grok/GPT invocations)
|
| 5 |
+
# - Safe default passthrough if a mode/task_type is unrecognized
|
| 6 |
|
| 7 |
+
# Retained import in case you reference it elsewhere; not used here.
|
| 8 |
+
from gpt_helpers import ask_gpt41_mini # noqa: F401
|
| 9 |
|
| 10 |
+
|
| 11 |
+
def _wrap(title: str, jurisdiction: str, content: str) -> str:
|
| 12 |
+
"""Minimal, consistent wrapper for returning labeled content."""
|
| 13 |
+
jur = f" ({jurisdiction})" if jurisdiction else ""
|
| 14 |
+
return f"{title}{jur}:\n\n{content}"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def process_task_response(task_type: str, grok_response: str, prompt: str, jurisdiction: str) -> str:
|
| 18 |
"""
|
| 19 |
+
Post-process Grok output for display/download. This function is intentionally lightweight:
|
| 20 |
+
- No additional retrieval or model calls
|
| 21 |
+
- Just adds consistent headings or minimal formatting per task type
|
| 22 |
+
- Safe passthrough for unknown types
|
| 23 |
"""
|
| 24 |
+
tt = (task_type or "").lower()
|
| 25 |
+
|
| 26 |
+
# Legacy/primary types
|
| 27 |
+
if tt in ("case_law", "irac"):
|
| 28 |
+
return _wrap("Case Law / IRAC Analysis", jurisdiction, grok_response)
|
| 29 |
+
if tt == "statute":
|
| 30 |
+
return _wrap("Statute Analysis", jurisdiction, grok_response)
|
| 31 |
+
if tt == "document_creation":
|
| 32 |
+
return _wrap("Final Document", jurisdiction, grok_response)
|
| 33 |
+
if tt == "document_analysis":
|
| 34 |
+
return _wrap("Document Analysis", jurisdiction, grok_response)
|
| 35 |
+
if tt == "legal_strategy":
|
| 36 |
+
return _wrap("Legal Strategy", jurisdiction, grok_response)
|
| 37 |
+
|
| 38 |
+
# Existing misc types (kept for compatibility with any callers you might have)
|
| 39 |
+
if tt == "analogical_reasoning":
|
| 40 |
+
return _wrap("Analogical Reasoning", jurisdiction, grok_response)
|
| 41 |
+
if tt in ("deposition_questions", "deposition_qs"):
|
| 42 |
+
return _wrap("Deposition Questions", jurisdiction, grok_response)
|
| 43 |
+
if tt == "verdict_predictor":
|
| 44 |
+
return _wrap("Verdict Prediction", jurisdiction, grok_response)
|
| 45 |
+
if tt == "damages_estimator":
|
| 46 |
+
return _wrap("Damages Estimate", jurisdiction, grok_response)
|
| 47 |
+
if tt == "pleading_validator":
|
| 48 |
+
return _wrap("Pleading Validation", jurisdiction, grok_response)
|
| 49 |
+
if tt == "legal_inbox":
|
| 50 |
+
return _wrap("Legal Inbox Processing", jurisdiction, grok_response)
|
| 51 |
+
if tt == "privilege_analyzer":
|
| 52 |
+
return _wrap("Privilege/PII Analysis", jurisdiction, grok_response)
|
| 53 |
+
if tt == "eli5":
|
| 54 |
+
return _wrap("Plain-English Explanation", jurisdiction, grok_response)
|
| 55 |
+
if tt == "workflow_template":
|
| 56 |
+
return _wrap("Workflow Template", jurisdiction, grok_response)
|
| 57 |
+
|
| 58 |
+
# New modes introduced in app.py
|
| 59 |
+
if tt == "citation_check":
|
| 60 |
+
return _wrap("Citation Check / Shepardizing-lite", jurisdiction, grok_response)
|
| 61 |
+
if tt == "brief_builder":
|
| 62 |
+
return _wrap("Brief Builder (IRAC Sections)", jurisdiction, grok_response)
|
| 63 |
+
if tt in ("deposition_qa",):
|
| 64 |
+
return _wrap("Deposition Q&A Generator", jurisdiction, grok_response)
|
| 65 |
+
if tt == "checklist":
|
| 66 |
+
return _wrap("Checklist & Red Flags", jurisdiction, grok_response)
|
| 67 |
+
if tt == "comparative_law":
|
| 68 |
+
return _wrap("Comparative Law", jurisdiction, grok_response)
|
| 69 |
+
if tt == "client_summary":
|
| 70 |
+
return _wrap("Client-Friendly Summary", jurisdiction, grok_response)
|
| 71 |
+
if tt == "motion_skeleton":
|
| 72 |
+
return _wrap("Motion Skeleton", jurisdiction, grok_response)
|
| 73 |
+
if tt == "opposing_argument":
|
| 74 |
+
return _wrap("Opposing Argument (Devil's Advocate)", jurisdiction, grok_response)
|
| 75 |
+
if tt == "case_extractor":
|
| 76 |
+
return _wrap("Case/Citation Extractor", jurisdiction, grok_response)
|
| 77 |
+
if tt == "judge_style":
|
| 78 |
+
return _wrap("Judge/County Style Adaptation", jurisdiction, grok_response)
|
| 79 |
+
if tt == "general_qa":
|
| 80 |
+
return _wrap("General Q&A", jurisdiction, grok_response)
|
| 81 |
+
|
| 82 |
+
# Fallback passthrough
|
| 83 |
+
return grok_response
|