fix(memory_agent): handle draft run without current release
- Add TODO comment to verify end_user sources (chat, draft, apikey) - Comment out release validation check to support draft run mode - Add TODO note explaining temporary fix for draft execution - Handle null current_release_id in result by returning None instead of failing - Improve import formatting for MemoryConfig model import statement - Allow configuration retrieval when app has no published release
This commit is contained in:
@@ -1165,6 +1165,7 @@ def get_end_user_connected_config(end_user_id: str, db: Session) -> Dict[str, An
|
|||||||
|
|
||||||
logger.info(f"Getting connected config for end_user: {end_user_id}")
|
logger.info(f"Getting connected config for end_user: {end_user_id}")
|
||||||
|
|
||||||
|
# TODO: check sources for enduserid, should be one of these three: chat, draft, apikey
|
||||||
# 1. 获取 end_user 及其 app_id
|
# 1. 获取 end_user 及其 app_id
|
||||||
end_user = db.query(EndUser).filter(EndUser.id == end_user_id).first()
|
end_user = db.query(EndUser).filter(EndUser.id == end_user_id).first()
|
||||||
if not end_user:
|
if not end_user:
|
||||||
@@ -1179,10 +1180,10 @@ def get_end_user_connected_config(end_user_id: str, db: Session) -> Dict[str, An
|
|||||||
if not app:
|
if not app:
|
||||||
logger.warning(f"App not found: {app_id}")
|
logger.warning(f"App not found: {app_id}")
|
||||||
raise ValueError(f"应用不存在: {app_id}")
|
raise ValueError(f"应用不存在: {app_id}")
|
||||||
|
# TODO: temp fix for draft run
|
||||||
if not app.current_release_id:
|
# if not app.current_release_id:
|
||||||
logger.warning(f"No current release for app: {app_id}")
|
# logger.warning(f"No current release for app: {app_id}")
|
||||||
raise ValueError(f"应用未发布: {app_id}")
|
# raise ValueError(f"应用未发布: {app_id}")
|
||||||
|
|
||||||
# 3. 兼容旧数据:如果 memory_config_id 为空,从 AppRelease.config 获取并回填
|
# 3. 兼容旧数据:如果 memory_config_id 为空,从 AppRelease.config 获取并回填
|
||||||
memory_config_id_to_use = end_user.memory_config_id
|
memory_config_id_to_use = end_user.memory_config_id
|
||||||
@@ -1223,7 +1224,9 @@ def get_end_user_connected_config(end_user_id: str, db: Session) -> Dict[str, An
|
|||||||
|
|
||||||
if legacy_config_id:
|
if legacy_config_id:
|
||||||
# 验证提取的 config_id 是否存在于数据库中
|
# 验证提取的 config_id 是否存在于数据库中
|
||||||
from app.models.memory_config_model import MemoryConfig as MemoryConfigModel
|
from app.models.memory_config_model import (
|
||||||
|
MemoryConfig as MemoryConfigModel,
|
||||||
|
)
|
||||||
existing_config = db.get(MemoryConfigModel, legacy_config_id)
|
existing_config = db.get(MemoryConfigModel, legacy_config_id)
|
||||||
|
|
||||||
if existing_config:
|
if existing_config:
|
||||||
@@ -1257,7 +1260,7 @@ def get_end_user_connected_config(end_user_id: str, db: Session) -> Dict[str, An
|
|||||||
result = {
|
result = {
|
||||||
"end_user_id": str(end_user_id),
|
"end_user_id": str(end_user_id),
|
||||||
"app_id": str(app_id),
|
"app_id": str(app_id),
|
||||||
"release_id": str(app.current_release_id),
|
"release_id": str(app.current_release_id) if app.current_release_id else None,
|
||||||
"memory_config_id": memory_config_id,
|
"memory_config_id": memory_config_id,
|
||||||
"workspace_id": str(app.workspace_id)
|
"workspace_id": str(app.workspace_id)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user