Part 2: Production Features - Provider wrappers, policy enforcement, sessions, और observability।
Setup
हम “CloudDash” नाम के एक fictional SaaS product के लिए customer support chatbot बना रहे हैं — यह एक cloud monitoring dashboard है। यह chatbot pricing, features, और troubleshooting के बारे में सवालों के जवाब देता है। साथ ही, हम हर layer पर RAIL Score evaluation add करेंगे ताकि chatbot के responses safe, accurate, fair, और helpful हों।Dependencies install करें
Environment variables
एक.env file बनाएँ:
अपनी RAIL API key लें: responsibleailabs.ai/dashboard पर sign up करें। Free tier में 100 credits मिलते हैं — इस पूरे tutorial को follow करने के लिए काफ़ी हैं।
Basic chatbot बनाएँ
पहले OpenAI से directly एक basic chatbot बनाएँ, बिना किसी RAIL integration के। यही वो foundation है जिस पर हम scoring layer करेंगे।chatbot.py
RAIL Score evaluation add करें
RAIL evaluation add करने का सबसे simple तरीकाRailScoreClient use करना है। एक ही call से सभी 8 RAIL dimensions के scores मिल जाते हैं।
chatbot_with_eval.py
Example output
Example output
Results को समझें
Deep evaluation
Basic mode आपको scores देता है। Deep mode आपको why बताता है: हर dimension की explanations, detected issues, और improvement suggestions।deep_eval.py
Example output
Example output
Basic vs Deep
आगे क्या है
Part 2: Production Features
Provider wrappers, policy enforcement (block/regenerate), multi-turn session tracking, और Langfuse observability।