1
1
from pydantic import BaseModel , Field
2
2
from typing import List , Optional , Dict , Any
3
3
4
+ # Existing schemas (keep unchanged)
4
5
class IngestionRequest (BaseModel ):
5
6
file_paths : List [str ] = Field (..., description = "List of file paths to ingest" )
6
7
chunking_strategy : str = Field ("medical" , description = "Chunking strategy" )
@@ -14,21 +15,74 @@ class IngestionResponse(BaseModel):
14
15
documents_stored : int
15
16
error : Optional [str ] = None
16
17
18
+ class SystemStatusResponse (BaseModel ):
19
+ status : str
20
+ vector_store_connected : bool
21
+ embedding_model_loaded : bool
22
+ documents_count : int
23
+ system_ready : bool
24
+
25
+ # UPDATED: Enhanced MedicalQueryRequest with session support
17
26
class MedicalQueryRequest (BaseModel ):
18
27
query : str = Field (..., description = "Medical query" , min_length = 1 )
19
28
max_chunks : Optional [int ] = Field (3 , description = "Max chunks to retrieve" )
29
+ session_id : Optional [str ] = Field (None , description = "Conversation session ID" )
20
30
31
+ # UPDATED: Enhanced MedicalQueryResponse with session info
21
32
class MedicalQueryResponse (BaseModel ):
22
33
success : bool
23
34
query : str
24
35
response : str
25
- sources : List [str ]
26
- processing_time : float
36
+ session_id : str
37
+ conversation_context_used : bool = Field (False , description = "Whether conversation context was used" )
38
+ sources : List [str ] = []
39
+ urgency_level : str = "routine"
40
+ chunks_used : int = 0
41
+ generation_time : float = 0.0
42
+ model_used : str = "gemini-1.5-flash"
43
+ safety_validated : bool = True
44
+ emergency_detected : bool = False
45
+ timestamp : str
46
+ processing_time : float = 0.0 # For backward compatibility
27
47
error : Optional [str ] = None
28
48
29
- class SystemStatusResponse (BaseModel ):
30
- status : str
31
- vector_store_connected : bool
32
- embedding_model_loaded : bool
33
- documents_count : int
34
- system_ready : bool
49
+ # NEW: Session management schemas
50
+ class SessionCreateResponse (BaseModel ):
51
+ session_id : str
52
+ message : str = "New conversation session created"
53
+
54
+ class SessionHistoryResponse (BaseModel ):
55
+ session_id : str
56
+ messages : List [Dict [str , Any ]]
57
+ message_count : int
58
+ created_at : str
59
+ updated_at : str
60
+
61
+ class SessionStatusResponse (BaseModel ):
62
+ session_id : str
63
+ exists : bool
64
+ message_count : int = 0
65
+ last_activity : Optional [str ] = None
66
+
67
+ class ChatMessage (BaseModel ):
68
+ role : str # 'user' or 'assistant'
69
+ content : str
70
+ timestamp : str
71
+ metadata : Optional [Dict [str , Any ]] = None
72
+
73
+ # NEW: Unified chat request (works with or without session)
74
+ class ChatRequest (BaseModel ):
75
+ query : str = Field (..., min_length = 1 , max_length = 1000 , description = "User's message" )
76
+ session_id : Optional [str ] = Field (None , description = "Optional session ID for conversation continuity" )
77
+ max_chunks : Optional [int ] = Field (3 , description = "Max retrieval chunks" )
78
+
79
+ class ChatResponse (BaseModel ):
80
+ success : bool
81
+ query : str
82
+ response : str
83
+ session_id : str
84
+ conversation_context_used : bool = False
85
+ sources : List [str ] = []
86
+ generation_time : float
87
+ timestamp : str
88
+ error : Optional [str ] = None
0 commit comments