feat(memory): add workspace_id fallback support for memory config resolution
- Add workspace_id fallback parameter to memory config loading across all services - Update hot_memory_tags.py to pass workspace_id when resolving memory configuration - Enhance emotion_analytics_service.py to support workspace_id as fallback for config resolution - Improve implicit_memory_service.py with workspace_id fallback in config loading - Update memory_agent_service.py to handle workspace_id resolution and add refactoring TODO - Enhance preference_analysis.jinja2 prompt with critical guidance on supporting_evidence extraction - Add validation to check both config_id and workspace_id before raising configuration errors - Improve error handling and logging for memory configuration resolution across services - This enables more flexible memory configuration resolution when config_id is unavailable
This commit is contained in:
@@ -1253,10 +1253,22 @@ def long_term_storage_window_task(
|
||||
# Save to Redis buffer first
|
||||
write_store.save_session_write(end_user_id, await chat_data_format(langchain_messages))
|
||||
|
||||
# Load memory config
|
||||
# Get workspace_id from end_user for fallback
|
||||
from app.models.app_model import App
|
||||
from app.models.end_user_model import EndUser
|
||||
|
||||
workspace_id = None
|
||||
end_user = db.query(EndUser).filter(EndUser.id == end_user_id).first()
|
||||
if end_user:
|
||||
app = db.query(App).filter(App.id == end_user.app_id).first()
|
||||
if app:
|
||||
workspace_id = app.workspace_id
|
||||
|
||||
# Load memory config with workspace fallback
|
||||
config_service = MemoryConfigService(db)
|
||||
memory_config = config_service.load_memory_config(
|
||||
config_id=config_id,
|
||||
workspace_id=workspace_id,
|
||||
service_name="LongTermStorageTask"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user