修复。image_batch_service.py 中的 claim.task_snapshot 是 SimpleNamespace(ChatGenerationTask 的快照),传给 owner_include_media_references() 时因为类型不匹配报错
This commit is contained in:
@@ -55,6 +55,11 @@ def owner_type_of(owner: GenerationOwner) -> str:
|
||||
return GenerationOwnerType.CHAT_GENERATION_TASK.value
|
||||
if isinstance(owner, GenerationRecord):
|
||||
return GenerationOwnerType.GENERATION_RECORD.value
|
||||
# 兼容 SimpleNamespace 快照(如 image_batch 的 task_snapshot)
|
||||
if hasattr(owner, 'generation_mode'):
|
||||
return GenerationOwnerType.CHAT_GENERATION_TASK.value
|
||||
if hasattr(owner, 'include_media_references'):
|
||||
return GenerationOwnerType.GENERATION_RECORD.value
|
||||
raise TypeError(f"不支持的生成任务对象: {type(owner)!r}")
|
||||
|
||||
|
||||
@@ -67,6 +72,11 @@ def owner_include_media_references(owner: GenerationOwner) -> bool:
|
||||
return True
|
||||
if isinstance(owner, GenerationRecord):
|
||||
return bool(owner.include_media_references)
|
||||
# 兼容 SimpleNamespace 快照(如 image_batch 的 task_snapshot)
|
||||
if hasattr(owner, 'generation_mode'):
|
||||
return True
|
||||
if hasattr(owner, 'include_media_references'):
|
||||
return bool(owner.include_media_references)
|
||||
raise TypeError(f"不支持的生成任务对象: {type(owner)!r}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user