graph TB
U[Родитель]
API[FastAPI Server
localhost:8000]
R[Gemini 2.5 Flash
Router & Classifier
$0.30/1M tokens]
G[Claude 3.5 Haiku
Response Generator
$0.25/$1.25/1M tokens]
SD[Social Detector
50+ patterns]
HM[History Manager
10 messages]
SS[Social State]
SR[Social Responder]
KB[(Documents
9 MD files)]
U -->|POST /chat| API
API -->|Process| R
R --> SD
R --> HM
R --> SS
R --> KB
R -->|Generate| G
G --> HM
G --> SR
API -->|JSON Response| U
style U fill:#e1f5fe
style API fill:#fff3e0
style R fill:#f3e5f5
style G fill:#f3e5f5
style KB fill:#e8f5e9
sequenceDiagram
participant U as Родитель
participant API as FastAPI
participant R as Gemini Router
participant G as Claude Generator
participant DB as Knowledge Base
U->>+API: POST /chat
API->>+R: Process message
Note over R: Check social intent
Get history context
R->>DB: Search relevant docs
DB-->>R: Return documents
R-->>API: RouterResponse
API->>+G: Generate response
Note over G: Generate with
social context
100-150 words
G-->>-API: Final response
API-->>-U: JSON response
Note over U: Time 5-7 sec
Cost ~$0.0015
flowchart TD
Start([User Message]) --> Check{Check Type}
Check -->|Pure Social| Social[Quick Response]
Check -->|Has Business| Router[Send to Router]
Social --> Return([Return Response])
Router --> Classify{Classification}
Classify -->|Success| Generate[Generate with Claude]
Classify -->|Offtopic| Template[Return Template]
Classify -->|Complex| Simplify[Ask to Simplify]
Generate --> AddContext[Add Social Context]
AddContext --> Return
Template --> Return
Simplify --> Return
style Start fill:#e1f5fe
style Return fill:#e8f5e9
style Generate fill:#f3e5f5
style Router fill:#fff3e0
pie title Распределение типов запросов
"Вопросы о курсах" : 35
"Цены и скидки" : 25
"Расписание" : 15
"Преподаватели" : 10
"Социальные приветствия" : 10
"Offtopic" : 5