File size: 2,046 Bytes
16d5a75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import Optional, List, Dict, Any
from pydantic import BaseModel, Field


class ChatMessage(BaseModel):
    content: str = Field(..., title="Message content")
    type: str = Field(..., title="Message type (human/ai)")


class AdaptiveChatBody(BaseModel):
    query: str = Field(..., title="User's query message")
    session_id: Optional[str] = Field(None, title="Session ID for tracking conversation")
    history: Optional[List[ChatMessage]] = Field(None, title="Chat history")
    current_system_prompt: Optional[str] = Field(None, title="Current system prompt being used")
    user_profile: Optional[Dict[str, Any]] = Field(None, title="User profile information if available")
    model_config = {
        "json_schema_extra": {
            "example": {
                "query": "Tôi muốn tìm hiểu về machine learning",
                "session_id": "abc123",
                "history": [
                    {"content": "Xin chào", "type": "human"},
                    {
                        "content": "Xin chào! Tôi có thể giúp gì cho bạn?",
                        "type": "ai",
                    },
                ],
                "current_system_prompt": "Bạn là trợ lý AI hữu ích, trả lời câu hỏi người dùng một cách chính xác và đầy đủ.",
                "user_profile": {
                    "technical_level": "beginner",
                    "preferred_style": "friendly",
                    "interests": ["AI", "programming"]
                }
            }
        }
    }


class AdaptiveChatResponse(BaseModel):
    bot_message: str = Field(..., title="Bot's response message")
    updated_system_prompt: Optional[str] = Field(None, title="Updated system prompt")
    session_id: str = Field(..., title="Session ID for tracking conversation")
    probing_questions: Optional[List[str]] = Field(None, title="Questions to probe user for more information")
    user_profile_updates: Optional[Dict[str, Any]] = Field(None, title="Updates to the user profile")