Part 1: एक Responsible AI Chatbot बनाएँ - Setup, basic evaluation, deep analysis, और scores को समझना।
Drop-in provider wrappers
हर LLM call के बाद manuallyrail.eval() call करने की ज़रूरत नहीं — provider wrappers use करें। ये LLM call और response evaluation एक ही shot में कर देते हैं।
OpenAI के साथ RAILOpenAI
chatbot_openai_wrapper.py
Gemini के साथ RAILGemini
chatbot_gemini_wrapper.py
Same RAIL evaluation, कोई भी provider। Wrapper internally provider-specific API call handle करता है, फिर response पर RAIL evaluation run करता है।
Policy enforcement: block और regenerate
Scoring बताता है कि response कितना अच्छा है। Policy enforcement system को बताता है कि इसके बारे में क्या करना है। दो policies हैं: BLOCK (reject करो और error raise करो) और REGENERATE (Safe-Regenerate endpoint से auto-improve करो)।Policy.BLOCK
policy_block.py
Policy.REGENERATE
policy_regenerate.py
कौन सी policy कब use करें
Multi-turn session management
Real chatbots multi-turn होते हैं। लंबी conversation में quality drift हो सकती है।RAILSession पूरी conversation में scores track करता है और aggregate metrics देता है।
chatbot_session.py
User messages को pre-screen करें
Session summary
Langfuse observability
Production में सिर्फ़ scores काफ़ी नहीं होते। आपको dashboards, trends, और alerts चाहिए।RAILLangfuse integration RAIL scores को Langfuse traces में numeric evaluation metrics के रूप में push करता है।
एक call में evaluate और log करें
chatbot_langfuse.py
Attach existing result
Full production integration
chatbot_production.py
Bonus: compliance check
अगर आपका chatbot personal data handle करता है या किसी regulated industry में operate करता है, तो specific frameworks (GDPR, CCPA, HIPAA, EU AI Act, वगैरह) के against compliance check run करें।compliance_check.py
Supported frameworks: GDPR, CCPA, HIPAA, EU AI Act, India DPDP Act, India AI Governance। Full details के लिए Compliance API reference देखें।
हमने क्या बनाया
- Basic evaluation: हर response पर 8-dimension scoring (1 credit)
- Deep evaluation: explanations, issues, और suggestions (3 credits)
- Provider wrappers: OpenAI और Gemini drop-in clients के साथ automatic scoring
- Policy enforcement: Unsafe responses को BLOCK करें या automatically REGENERATE करें
- Session tracking: Multiple turns में conversation quality monitor करें
- Langfuse observability: सभी scores को monitoring dashboard में push करें
- Compliance checks: GDPR, HIPAA, EU AI Act, वगैरह के against verify करें
आगे क्या है
API Reference
Evaluation, generation, और compliance के लिए full endpoint documentation।
Python SDK Docs
Complete SDK reference: sync/async clients, middleware, सभी integrations।
Credits और Pricing
Basic, deep, protected, और compliance endpoints में credits कैसे काम करते हैं।
RAIL Framework
सभी 8 RAIL dimensions और scoring methodology की deep dive।