Aimpress_site/chatbot-api/models.py
Vadym Samoilenko 73b1a0feda Add AI chatbot: FastAPI backend + React chat widget
- Python FastAPI backend (chatbot-api/) with Claude Sonnet 4.6, prompt injection
  protection, rate limiting (30 msg/session), off-topic filtering, Redis session storage
- Rocket.Chat integration for live monitoring and human takeover
- Lead capture via n8n webhook
- React chat widget: floating bubble, auto-greeting after 30s, glassmorphism chat
  window, mobile responsive, lazy loaded, Mixpanel analytics
- Nginx proxy /api/chat → chatbot-api:8000
- Docker: chatbot-api + Redis services added to docker-compose

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 17:14:07 +00:00

29 lines
680 B
Python

from pydantic import BaseModel, Field
class ChatRequest(BaseModel):
session_id: str = Field(..., min_length=1, max_length=64)
message: str = Field(..., min_length=1, max_length=500)
page_context: str = Field(default="/", max_length=200)
class ChatResponse(BaseModel):
reply: str
sender: str = "bot" # "bot" | "human"
session_id: str
message_count: int
rate_limited: bool = False
class LeadData(BaseModel):
name: str = ""
email: str = ""
company: str = ""
need: str = ""
class RocketChatWebhook(BaseModel):
token: str = ""
channel_id: str = ""
user_name: str = ""
text: str = ""