Spaces:
Sleeping
Sleeping
1. Layer 1 β Privacy: Complaint ID PII Protection
- 1.1 Add
_complaint_id_deny_recognizer()function insrc/privacy/redactor.pythat returns aPatternRecognizerwith entity typeCOMPLAINT_REF_ID, regex matchingREF-,TRN-,TXN-,OD-,BK-,CLM-,CASE-,CMP-,LN-,POL-,CR-prefixed IDs (score 0.99), and a comment explaining intentional exclusion from_ENTITY_TYPES - 1.2 Register the
_complaint_id_deny_recognizer()inPIIRedactor.__init__alongside the existing Indian recognizers - 1.3 Verify manually:
PIIRedactor().redact("REF-20260501-001")returns text withREF-20260501-001unchanged;PIIRedactor().redact("account 9876543210")still returns<US_BANK_NUMBER>
2. Layer 1 β Infrastructure: Tesseract Pre-flight
- 2.1 Add a
_check_tesseract()function instart.pyusingshutil.which("tesseract")that prints a formatted error with macOS/Ubuntu/Windows install commands and callssys.exit(1)if the binary is absent - 2.2 Call
_check_tesseract()instart.pybefore theuvicornserver launch block (after argument parsing, before training or server startup) - 2.3 Verify manually: rename/hide the tesseract binary temporarily and confirm
python start.pyexits with code 1 and prints install instructions
3. Layer 3 β Prompt: Rule 4/5 Tightening
- 3.1 In
src/agent/prompts.pyRule 4, append after the tab-navigation instruction: "Do not append a yes/no follow-up question ('Does this look correct?', 'Shall I proceed?', etc.). The numbered summary above is the confirmation request. Stop completely and wait for[USER CONFIRMED]:." - 3.2 In Rule 5, replace "The most recent user message begins with" with "You have received a user message that begins with" to eliminate turn-ordering ambiguity
- 3.3 Verify by running Trace 07 scenario: agent should present numbered summary and stop without asking an extra question
4. Layer 3 β Prompt: HITL Structured JSON Block
- 4.1 In
src/agent/prompts.pyRule 4, add an instruction immediately after the numbered list template: the agent SHALL append<!--ENTITIES:{"provider":..., "incident_date":..., "amount":..., "reference_id":..., "prior_contact":..., "desired_resolution":...}-->with the same values as the numbered list; omit keys for unknown fields; use string values for all fields includingprior_contact("Yes"/"No")
5. Layer 4 β UI: Structured Entity Parsing
- 5.1 Add
_parse_hitl_entities_json(reply: str) -> dictfunction inui/app.pythat extracts the<!--ENTITIES:{...}-->comment, callsjson.loads, and returns the dict (returns{}on any parse error or absent block) - 5.2 Replace the call to
_parse_hitl_entities(reply)in_handle_chatwith_parse_hitl_entities_json(reply) - 5.3 Remove the
_parse_hitl_entitiesfunction and_HITL_PATTERNSdict (now unused)
6. Layer 4 β UI: prior_contact Guard
- 6.1 In
_handle_confirminui/app.py, change theprior_contactentry from"prior_contact": prior == "Yes"to"prior_contact": Trueonly whenprior == "Yes", and omit the key entirely whenpriorisNone, empty string, or"No"β align with the filter condition on line 596
7. Layer 4 β UI: _extract_draft Relaxation
- 7.1 In
_extract_draftinui/app.py, add a third extraction path between the---primary and theSubject:fallback:re.search(r'(Subject:.+)', reply, re.DOTALL | re.IGNORECASE)that returns fromSubject:to end of string when no closing---is present - 7.2 Fix the existing
"Subject:" in replyfallback to returnreply[reply.index("Subject:"):]instead of the fullreplystring
8. Layer 2 β ML: NER ORG List Extension
- 8.1 In
src/ner/train.py_ENTITY_VALUES["ORG"]list, add:"Indian Bank","Niva Bupa","Care Health Insurance","Bajaj Allianz","Agoda","OYO Rooms","Booking.com India","Razorpay","BharatPe","CRED" - 8.2 Retrain EvidenceNER checkpoint:
python -m src.ner.train --output_dir models/evidence_ner - 8.3 Verify:
extract_entities("Indian Bank charged 1000 rupee")returns an entity withlabel="ORG"and text matching "Indian Bank"
9. Layer 2 β ML: Domain Classifier Rebalancing
- 9.1 In
src/classifier/train.py_SUPPLEMENT_TEMPLATES["telecom"], add 10 new templates covering SIM activation, prepaid recharge, porting, deactivation scenarios; add 5 Agoda/OYO/Booking.com templates toecommerce - 9.2 Change the
supplement_per_classdefault in_build_supplement()signature from2_000to5_000 - 9.3 Change the
--supplement_per_classCLI argument default intrain.pyfrom2_000to5_000 - 9.4 Retrain DomainClassifier checkpoint on Kaggle: zip
src/classifier/train.py+ CFPB CSV, runpython -m src.classifier.train --cfpb_csv data/raw/complaints.csv --output_dir models/domain_classifier, download and replacemodels/domain_classifier/ - 9.5 Verify:
classify("I bought a new sim card from BSNL for rs 450 but sim card is not yet activated")returnsdomain="telecom"withlow_confidence=False