chatbot_ai_safety / models.py
happygold's picture
Synced repo using 'sync_with_huggingface' Github Action
85d4baf
raw
history blame contribute delete
638 Bytes
"""Schemas for the chat app."""
from pydantic import BaseModel, validator
class ChatResponse(BaseModel):
"""Chat response schema."""
sender: str
message: str
source_documents: list = []
chat_history: list = []
type: str
@validator("sender")
def sender_must_be_bot_or_you(cls, v):
if v not in ["bot", "you"]:
raise ValueError("sender must be bot or you")
return v
@validator("type")
def validate_message_type(cls, v):
if v not in ["start", "stream", "end", "error", "info"]:
raise ValueError("type must be start, stream or end")
return v