How shreyasskrishna/pii_masking_with_opik_security works
This is a privacy-preserving customer-support chatbot exposed through a FastAPI service. The main workflow accepts a chat request, masks personal information, obtains a Groq-generated response, restores PII for the user-facing result, and records quality/trace data. The API also offers masked search results, trace-linked feedback, and a report of unmasked conversation history. The excerpts show the API routes and major processing stages, but omit some calls inside the bot; the persistence edge from bot to database is therefore marked unverified.
Main entry points: customer_support_bot.py Support Bot · api.py FastAPI Service · db_manager.py DB Manager
Components 17
API and Reporting
- FastAPI Service
customer_support_ai/api.py - Masked Search
customer_support_ai/api.py - History Report
customer_support_ai/api.py - Feedback Route
customer_support_ai/api.py
Chat Processing
- Support Bot
customer_support_ai/customer_support_bot.py - Input Validation
customer_support_ai/customer_support_bot.py - PII Masking
customer_support_ai/customer_support_bot.py - Prompt Construction
customer_support_ai/customer_support_bot.py - Groq Client
customer_support_ai/customer_support_bot.py - Response Unmasking
customer_support_ai/customer_support_bot.py
Observability
- Quality Evaluation
customer_support_ai/customer_support_bot.py - Opik Tracing
customer_support_ai/customer_support_bot.py
Conversation Storage
- DB Manager
customer_support_ai/db_manager.py - MongoDB
Other components
- Chat User
- Groq LLM
- Opik Service
Connections 17
- Chat User → FastAPI Service: submits chat
customer_support_ai/api.py - FastAPI Service → Masked Search: routes search
customer_support_ai/api.py - Masked Search → Support Bot: processes message
customer_support_ai/api.py - Support Bot → Input Validation: validates input
customer_support_ai/customer_support_bot.py - Support Bot → PII Masking: masks PII
customer_support_ai/customer_support_bot.py - Support Bot → Prompt Construction: builds prompt
customer_support_ai/customer_support_bot.py - Support Bot → Groq Client: invokes client
customer_support_ai/customer_support_bot.py - Groq Client → Groq LLM: sends request
customer_support_ai/customer_support_bot.py - Support Bot → Response Unmasking: unmasks response
customer_support_ai/customer_support_bot.py - Support Bot → Quality Evaluation: scores response
customer_support_ai/customer_support_bot.py - Support Bot → Opik Tracing: records trace
customer_support_ai/customer_support_bot.py - Feedback Route → Opik Service: logs feedback
customer_support_ai/api.py - Opik Tracing → Opik Service: exports traces
- FastAPI Service → History Report: routes report
customer_support_ai/api.py - History Report → DB Manager: reads history
customer_support_ai/api.py - DB Manager → MongoDB: queries and inserts
customer_support_ai/db_manager.py - Support Bot → DB Manager: persists turns
customer_support_ai/customer_support_bot.py