The Chat component creates an AI-powered assistant that can answer questions based on your study materials. It supports web search, RAG (Retrieval Augmented Generation), and multi-step reasoning.
Enable guardrails to apply server-side content policy rules to AI responses. When enabled, the AI’s responses will be evaluated against your configured rules before being returned to the user.
Guardrails allow you to apply server-side content policy rules to AI responses. When enabled, the AI’s responses are evaluated against your configured rules before being returned to the user.
const chatWithGuardrails = await client.v1.components.create({ name: 'Math Tutor with Guardrails', type: 'chat', config: { materials: ['mat-789'], model: 'gpt-4o-mini-2024-07-18', enableGuardrails: true, guardrailRules: [ { id: 'no-direct-answers', action: 'MODIFY', condition: 'Response provides direct answers to homework problems without explanation', description: 'Guide students to solve problems themselves', message: 'Modified to provide guidance instead of direct answers' }, { id: 'academic-honesty', action: 'WARN', condition: 'User asks for test or exam answers', description: 'Warn about academic integrity', message: 'Remember: This tool is for learning, not for completing graded assignments' } ] }});
The Chat API supports real-time streaming responses using Server-Sent Events (SSE). This allows you to display responses as they’re generated, providing a more interactive experience.