fix(app): memory config initialization for end users
- Add memory_config_id extraction and assignment when creating new end users in public share chat - Introduce get_or_create_end_user_with_config method to handle memory config setup in single transaction - Add batch_update_memory_config_id_by_app method for bulk updating end user memory configs - Rename _update_endusers_memory_config_by_workspace to _update_endusers_memory_config_by_app for correct scope - Update app publish flow to use app_id instead of workspace_id for memory config updates - Remove unused actual_end_user_id variable in langchain_agent - Ensures end users are properly associated with memory configs on creation and during app updates
This commit is contained in:
@@ -354,6 +354,16 @@ async def chat(
|
||||
other_id=other_id,
|
||||
original_user_id=user_id
|
||||
)
|
||||
|
||||
# Only extract and set memory_config_id when the end user doesn't have one yet
|
||||
if not new_end_user.memory_config_id:
|
||||
from app.services.memory_config_service import MemoryConfigService
|
||||
memory_config_service = MemoryConfigService(db)
|
||||
memory_config_id, _ = memory_config_service.extract_memory_config_id(release.type, release.config or {})
|
||||
if memory_config_id:
|
||||
new_end_user.memory_config_id = memory_config_id
|
||||
db.commit()
|
||||
db.refresh(new_end_user)
|
||||
end_user_id = str(new_end_user.id)
|
||||
|
||||
# appid = share.app_id
|
||||
|
||||
Reference in New Issue
Block a user