Spaces:
Sleeping
Sleeping
JerameeUC commited on
Commit Β·
ce5d63d
1
Parent(s): bc01a6a
15th Commit Fixed Readme files all the markdown to link between the documentation on GitHub
Browse files- README.md +7 -1
- docs/Brief_Academic_Write_Up.md +90 -0
- docs/DEV_DOC.md +9 -0
- docs/Developer_Guide_Build_Test.md +12 -0
- docs/architecture.md +10 -0
- docs/design.md +10 -0
README.md
CHANGED
|
@@ -104,7 +104,13 @@ pytest -q
|
|
| 104 |
|
| 105 |
## Documentation
|
| 106 |
|
| 107 |
-
- [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
---
|
| 110 |
|
|
|
|
| 104 |
|
| 105 |
## Documentation
|
| 106 |
|
| 107 |
+
- [Brief Academic Write Up](docs/Brief_Academic_Write_Up.md)
|
| 108 |
+
- [README](../README.md)
|
| 109 |
+
- [Architecture Overview](docs/architecture.md)
|
| 110 |
+
- [Design Notes](docs/design.md)
|
| 111 |
+
- [Implementation Notes](docs/storefront/IMPLEMENTATION.md)
|
| 112 |
+
- [Dev Doc](docs/DEV_DOC.md)
|
| 113 |
+
- [Developer Guide Build Test](docs/Developer_Guide_Build_Test.md)
|
| 114 |
|
| 115 |
---
|
| 116 |
|
docs/Brief_Academic_Write_Up.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Brief Academic Write-Up
|
| 2 |
+
*Agentic-Chat-bot β Design Rationale, Privacy Controls, and Compliance Posture*
|
| 3 |
+
|
| 4 |
+
## Abstract
|
| 5 |
+
This project implements an **agentic chatbot** with retrieval-augmented generation (RAG), session memory, and provider-agnostic connectors. The system emphasizes **modular architecture**, **resilience via graceful degradation**, and **privacy-by-design**. A key contribution is a **private-data header** mechanism that enforces local-only processing, aggressive redaction, and exclusion from bulk AI inputs, thereby mitigating legal and reputational risks associated with data resale and third-party remarketing (e.g., telemarketers undercutting pricing).
|
| 6 |
+
|
| 7 |
+
## System Overview
|
| 8 |
+
- **Modularity:** UI (web/Gradio), routing, NLU, memory/RAG, provider adapters, and guardrails are cleanly separated for testability and substitution.
|
| 9 |
+
- **Two Modes:**
|
| 10 |
+
- *Anonymous/Local*: offline or local-only inference with strict PII controls.
|
| 11 |
+
- *Logged-in/Cloud*: unifies external providers (OpenAI, Azure, HF, etc.) behind a single interface with timeouts and fallbacks.
|
| 12 |
+
- **RAG:** Documents (e.g., storefront policies/FAQs) are chunked and indexed; prompts are grounded to reduce hallucination and maintain domain compliance.
|
| 13 |
+
- **Guardrails & Redaction:** PII/PHI detection and masking precede any external call; logging is minimized and configurable.
|
| 14 |
+
|
| 15 |
+
## Methods
|
| 16 |
+
1. **Routing & Orchestration:** Requests pass through middleware: authentication, **privacy header detection**, PII/PHI redaction, policy checks, and capability routing (RAG vs. tools vs. LLM).
|
| 17 |
+
2. **Retrieval:** Sparse+dense retrieval with max-passage constraints; citations returned to the UI where applicable.
|
| 18 |
+
3. **Resilience:** Provider failures trigger fallback to local rules or safe canned responses; telemetry excludes sensitive content by default.
|
| 19 |
+
|
| 20 |
+
## Privacy Header for Customer Data
|
| 21 |
+
We introduce a deployment-standard header:
|
| 22 |
+
```
|
| 23 |
+
X-Private-Customer-Data: strict
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
**Semantic Policy (enforced in middleware before any provider call):**
|
| 27 |
+
- **Local-Only Processing:** Bypass external providers and long-term storage.
|
| 28 |
+
- **Aggressive Redaction:** Highest PII profile (names, emails, phones, addresses, payment tokens, order details); **no raw payload logging**.
|
| 29 |
+
- **RAG/Analytics Exclusion:** Do **not** index these sessions; **scrub** them from **bulk AI chat input**, training corpora, and aggregate analytics.
|
| 30 |
+
- **Default-Deny Egress:** Block third-party API calls, event streams, or data sharing unless a signed, compliant exception explicitly allows it.
|
| 31 |
+
|
| 32 |
+
**Business Rationale:**
|
| 33 |
+
This header materially reduces the risk of allegations of **selling customer data** and helps prevent leakage to data brokers and **telemarketing ecosystems** that could target your customers with **lower online prices**, which erodes trust and revenue.
|
| 34 |
+
|
| 35 |
+
### Example (FastAPI-style Middleware Sketch)
|
| 36 |
+
```python
|
| 37 |
+
from fastapi import Request, Response
|
| 38 |
+
|
| 39 |
+
PRIVATE_HEADER = "X-Private-Customer-Data"
|
| 40 |
+
STRICT_VALUE = "strict"
|
| 41 |
+
|
| 42 |
+
async def privacy_middleware(request: Request, call_next):
|
| 43 |
+
private = request.headers.get(PRIVATE_HEADER, "").lower() == STRICT_VALUE
|
| 44 |
+
request.state.private_mode = private
|
| 45 |
+
|
| 46 |
+
if private:
|
| 47 |
+
request.state.local_only = True
|
| 48 |
+
request.state.retain_logs = False
|
| 49 |
+
request.state.rag_exclude = True
|
| 50 |
+
request.state.redaction_profile = "max"
|
| 51 |
+
|
| 52 |
+
response: Response = await call_next(request)
|
| 53 |
+
return response
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Compliance Considerations (incl. HIPAA/Medical)
|
| 57 |
+
- **HIPAA Readiness (when handling PHI):**
|
| 58 |
+
- **Minimum Necessary:** Redact and limit exposure to only what is needed for the task.
|
| 59 |
+
- **No Third-Party Egress Without BAA:** External LLM/provider calls **disabled** unless there is a Business Associate Agreement.
|
| 60 |
+
- **Logging & Telemetry:** Content logs disabled; operational logs scrubbed; audit logs retained for access and policy decisions.
|
| 61 |
+
- **Data Lifecycle:** PHI-tagged messages **excluded from RAG indexes** and all analytics/training pipelines; ephemeral session memory with explicit TTLs.
|
| 62 |
+
- **Encryption & Access:** TLS in transit; encrypted at rest; role-based access; periodic key rotation.
|
| 63 |
+
- **Consumer Data Protection (non-PHI):**
|
| 64 |
+
- **Do-Not-Sell Policy:** Private header forces a do-not-sell/do-not-share posture for customer data.
|
| 65 |
+
- **Vendor Risk:** Egress controls prevent uncontracted processors from receiving sensitive customer information.
|
| 66 |
+
- **Incident Readiness:** Audit trails for provenance; fast revocation paths; breach notification procedures.
|
| 67 |
+
|
| 68 |
+
> **Note:** This section is a technical summary for engineering rigor and does not constitute legal advice.
|
| 69 |
+
|
| 70 |
+
## Evaluation & Threat Model (Brief)
|
| 71 |
+
- **Threats:** Data exfiltration (logs, analytics, 3rd-party APIs), prompt injection via retrieved content, ID linkage across sessions, and model inversion via public endpoints.
|
| 72 |
+
- **Mitigations:** Private header hard switch, strict PII redaction, retrieval allow-lists, content-security policies for UI, rate limiting, and anomaly detection on output length/entropy.
|
| 73 |
+
|
| 74 |
+
## Limitations & Future Work
|
| 75 |
+
- **Granular Policies:** Move from header-only to **policy objects** (per user, per org, per route) managed by an admin console.
|
| 76 |
+
- **Differential Privacy:** Explore noise mechanisms for aggregate analytics that exclude private sessions.
|
| 77 |
+
- **Continuous Redaction Tests:** Unit and fuzz tests for PII/PHI detectors; red-team prompt-injection suites.
|
| 78 |
+
|
| 79 |
+
## Documentation
|
| 80 |
+
|
| 81 |
+
- [README](../README.md)
|
| 82 |
+
- [Architecture Overview](architecture.md)
|
| 83 |
+
- [Design Notes](design.md)
|
| 84 |
+
- [Developer & Build/Test Guide](Developer_Guide_Build_Test.md)
|
| 85 |
+
- [Implementation Notes](storefront/IMPLEMENTATION.md)
|
| 86 |
+
- [Dev Doc](DEV_DOC.md)
|
| 87 |
+
- [This Document](Brief_Academic_Write_Up.md)
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
*Prepared for inclusion in the GitHub repository to document academic motivations, privacy mechanisms (private-data header), and compliance posture (including HIPAA considerations) for the Agentic-Chat-bot system.*
|
docs/DEV_DOC.md
CHANGED
|
@@ -96,3 +96,12 @@ Key components include:
|
|
| 96 |
- **NLP (Natural Language Processing):** A field of AI focused on enabling computers to understand human language.
|
| 97 |
- **Sentiment Analysis:** An NLP technique that determines the emotional tone behind a text.
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
- **NLP (Natural Language Processing):** A field of AI focused on enabling computers to understand human language.
|
| 97 |
- **Sentiment Analysis:** An NLP technique that determines the emotional tone behind a text.
|
| 98 |
|
| 99 |
+
## Documentation
|
| 100 |
+
|
| 101 |
+
- [Brief Academic Write Up](docs/Brief_Academic_Write_Up.md)
|
| 102 |
+
- [README](../README.md)
|
| 103 |
+
- [Architecture Overview](architecture.md)
|
| 104 |
+
- [Design Notes](design.md)
|
| 105 |
+
- [Implementation Notes](storefront/IMPLEMENTATION.md)
|
| 106 |
+
- [Dev Doc](DEV_DOC.md)
|
| 107 |
+
- [Developer Guide Build Test](Developer_Guide_Build_Test.md)
|
docs/Developer_Guide_Build_Test.md
CHANGED
|
@@ -118,4 +118,16 @@ curl -X POST http://127.0.0.1:3978/plain-chat -H "Content-Type: application/json
|
|
| 118 |
|
| 119 |
---
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
_Audience: Contributors & Developers_
|
|
|
|
| 118 |
|
| 119 |
---
|
| 120 |
|
| 121 |
+
## Documentation
|
| 122 |
+
|
| 123 |
+
- [Brief Academic Write Up](docs/Brief_Academic_Write_Up.md)
|
| 124 |
+
- [README](../README.md)
|
| 125 |
+
- [Architecture Overview](architecture.md)
|
| 126 |
+
- [Design Notes](design.md)
|
| 127 |
+
- [Implementation Notes](storefront/IMPLEMENTATION.md)
|
| 128 |
+
- [Dev Doc](DEV_DOC.md)
|
| 129 |
+
- [This Document](Developer_Guide_Build_Test.md)
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
_Audience: Contributors & Developers_
|
docs/architecture.md
CHANGED
|
@@ -71,3 +71,13 @@ This system follows a **modular chatbot architecture** built around a clear flow
|
|
| 71 |
## Summary
|
| 72 |
|
| 73 |
The architecture ensures a **clean separation between interface, logic, and services**, enabling experimentation with different providers while guaranteeing a safe, privacy-friendly anonymous mode. The flowchart illustrates this layered approach: input β logic β NLU/memory β optional AIaaS β guardrails β output.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
## Summary
|
| 72 |
|
| 73 |
The architecture ensures a **clean separation between interface, logic, and services**, enabling experimentation with different providers while guaranteeing a safe, privacy-friendly anonymous mode. The flowchart illustrates this layered approach: input β logic β NLU/memory β optional AIaaS β guardrails β output.
|
| 74 |
+
|
| 75 |
+
## Documentation
|
| 76 |
+
|
| 77 |
+
- [README](../README.md)
|
| 78 |
+
- [Architecture Overview](architecture.md)
|
| 79 |
+
- [Design Notes](design.md)
|
| 80 |
+
- [Developer & Build/Test Guide](Developer_Guide_Build_Test.md)
|
| 81 |
+
- [Implementation Notes](storefront/IMPLEMENTATION.md)
|
| 82 |
+
- [Dev Doc](DEV_DOC.md)
|
| 83 |
+
- [Developer Guide Build Test](Developer_Guide_Build_Test.md)
|
docs/design.md
CHANGED
|
@@ -70,3 +70,13 @@ These notes document the reasoning behind major design choices, focusing on **AP
|
|
| 70 |
## Summary
|
| 71 |
|
| 72 |
The design balances **privacy, modularity, and extensibility**. By cleanly separating anonymous and logged-in paths, the system can run entirely offline while still supporting richer AI features when configured. Security and privacy are first-class concerns, and tradeoffs were made to keep the system lightweight, testable, and compliant with project constraints.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
## Summary
|
| 71 |
|
| 72 |
The design balances **privacy, modularity, and extensibility**. By cleanly separating anonymous and logged-in paths, the system can run entirely offline while still supporting richer AI features when configured. Security and privacy are first-class concerns, and tradeoffs were made to keep the system lightweight, testable, and compliant with project constraints.
|
| 73 |
+
|
| 74 |
+
## Documentation
|
| 75 |
+
|
| 76 |
+
- [README](../README.md)
|
| 77 |
+
- [Architecture Overview](architecture.md)
|
| 78 |
+
- [Design Notes](design.md)
|
| 79 |
+
- [Developer & Build/Test Guide](Developer_Guide_Build_Test.md)
|
| 80 |
+
- [Implementation Notes](storefront/IMPLEMENTATION.md)
|
| 81 |
+
- [Dev Doc](DEV_DOC.md)
|
| 82 |
+
- [Developer Guide Build Test](Developer_Guide_Build_Test.md)
|