Spaces:
Sleeping
Sleeping
dylanglenister
commited on
Commit
·
a3cb67a
1
Parent(s):
75bec31
CHORE: Fix documentation
Browse files- src/core/memory_manager.py +1 -1
- src/core/response_pipeline.py +10 -10
src/core/memory_manager.py
CHANGED
|
@@ -226,7 +226,7 @@ class MemoryManager:
|
|
| 226 |
) -> str:
|
| 227 |
"""
|
| 228 |
Builds a rich, multi-source context string for a new question, combining
|
| 229 |
-
short-term memory, long-term semantic memory, and current conversation.
|
| 230 |
"""
|
| 231 |
context_parts = []
|
| 232 |
|
|
|
|
| 226 |
) -> str:
|
| 227 |
"""
|
| 228 |
Builds a rich, multi-source context string for a new question, combining
|
| 229 |
+
short-term memory, long-term semantic memory, information from the knowledge base, and current conversation.
|
| 230 |
"""
|
| 231 |
context_parts = []
|
| 232 |
|
src/core/response_pipeline.py
CHANGED
|
@@ -36,7 +36,11 @@ def _validate_user_query(message: str, safety_guard: SafetyGuard | None):
|
|
| 36 |
detail="Failed to validate user query safety."
|
| 37 |
) from e
|
| 38 |
|
| 39 |
-
def _validate_model_response(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
"""
|
| 41 |
Checks the generated model response against the safety guard.
|
| 42 |
Returns a safe fallback message if the response is deemed unsafe.
|
|
@@ -57,16 +61,12 @@ def _validate_model_response(query: str, response: str, safety_guard: SafetyGuar
|
|
| 57 |
return response
|
| 58 |
|
| 59 |
async def _retrieve_context(
|
| 60 |
-
state: AppState,
|
|
|
|
|
|
|
|
|
|
| 61 |
) -> str:
|
| 62 |
-
"""
|
| 63 |
-
Retrieves enhanced medical context. This is the entry point for RAG.
|
| 64 |
-
|
| 65 |
-
Future RAG Implementation:
|
| 66 |
-
1. Augment this function to query a vector database or knowledge base.
|
| 67 |
-
2. Combine the results with the existing memory manager context.
|
| 68 |
-
3. Return the consolidated context string.
|
| 69 |
-
"""
|
| 70 |
try:
|
| 71 |
return await state.memory_manager.get_enhanced_context(
|
| 72 |
session_id=session_id,
|
|
|
|
| 36 |
detail="Failed to validate user query safety."
|
| 37 |
) from e
|
| 38 |
|
| 39 |
+
def _validate_model_response(
|
| 40 |
+
query: str,
|
| 41 |
+
response: str,
|
| 42 |
+
safety_guard: SafetyGuard | None
|
| 43 |
+
) -> str:
|
| 44 |
"""
|
| 45 |
Checks the generated model response against the safety guard.
|
| 46 |
Returns a safe fallback message if the response is deemed unsafe.
|
|
|
|
| 61 |
return response
|
| 62 |
|
| 63 |
async def _retrieve_context(
|
| 64 |
+
state: AppState,
|
| 65 |
+
session_id: str,
|
| 66 |
+
patient_id: str,
|
| 67 |
+
message: str
|
| 68 |
) -> str:
|
| 69 |
+
"""Retrieves enhanced medical context. This is the entry point for RAG."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
try:
|
| 71 |
return await state.memory_manager.get_enhanced_context(
|
| 72 |
session_id=session_id,
|