mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 13:15:53 +08:00
refactor(identity): update model identity key
- Change "model_identity" to "dify_model_identity" for consistency - Adjust file validation logic to use updated key in various components and tests
This commit is contained in:
parent
5c64792793
commit
26c8beb804
@ -652,7 +652,7 @@ class WorkflowCycleManage:
|
||||
if not value:
|
||||
return None
|
||||
|
||||
if isinstance(value, dict) and value.get("model_identity") == FILE_MODEL_IDENTITY:
|
||||
if isinstance(value, dict) and value.get("dify_model_identity") == FILE_MODEL_IDENTITY:
|
||||
return value
|
||||
elif isinstance(value, File):
|
||||
return value.to_dict()
|
||||
|
@ -190,10 +190,10 @@ class WorkflowTool(Tool):
|
||||
for key, value in outputs.items():
|
||||
if isinstance(value, list):
|
||||
for item in value:
|
||||
if isinstance(item, dict) and item.get("model_identity") == FILE_MODEL_IDENTITY:
|
||||
if isinstance(item, dict) and item.get("dify_model_identity") == FILE_MODEL_IDENTITY:
|
||||
file = File.model_validate(item)
|
||||
files.append(file)
|
||||
elif isinstance(value, dict) and value.get("model_identity") == FILE_MODEL_IDENTITY:
|
||||
elif isinstance(value, dict) and value.get("dify_model_identity") == FILE_MODEL_IDENTITY:
|
||||
file = File.model_validate(value)
|
||||
files.append(file)
|
||||
|
||||
|
@ -213,7 +213,7 @@ class AnswerStreamProcessor(StreamProcessor):
|
||||
return None
|
||||
|
||||
if isinstance(value, dict):
|
||||
if "model_identity" in value and value["model_identity"] == FILE_MODEL_IDENTITY:
|
||||
if "dify_model_identity" in value and value["dify_model_identity"] == FILE_MODEL_IDENTITY:
|
||||
return value
|
||||
elif isinstance(value, File):
|
||||
return value.to_dict()
|
||||
|
@ -569,10 +569,10 @@ class Conversation(db.Model):
|
||||
def inputs(self):
|
||||
inputs = self._inputs.copy()
|
||||
for key, value in inputs.items():
|
||||
if isinstance(value, dict) and value.get("model_identity") == FILE_MODEL_IDENTITY:
|
||||
if isinstance(value, dict) and value.get("dify_model_identity") == FILE_MODEL_IDENTITY:
|
||||
inputs[key] = File.model_validate(value)
|
||||
elif isinstance(value, list) and all(
|
||||
isinstance(item, dict) and item.get("model_identity") == FILE_MODEL_IDENTITY for item in value
|
||||
isinstance(item, dict) and item.get("dify_model_identity") == FILE_MODEL_IDENTITY for item in value
|
||||
):
|
||||
inputs[key] = [File.model_validate(item) for item in value]
|
||||
return inputs
|
||||
@ -765,10 +765,10 @@ class Message(db.Model):
|
||||
def inputs(self):
|
||||
inputs = self._inputs.copy()
|
||||
for key, value in inputs.items():
|
||||
if isinstance(value, dict) and value.get("model_identity") == FILE_MODEL_IDENTITY:
|
||||
if isinstance(value, dict) and value.get("dify_model_identity") == FILE_MODEL_IDENTITY:
|
||||
inputs[key] = File.model_validate(value)
|
||||
elif isinstance(value, list) and all(
|
||||
isinstance(item, dict) and item.get("model_identity") == FILE_MODEL_IDENTITY for item in value
|
||||
isinstance(item, dict) and item.get("dify_model_identity") == FILE_MODEL_IDENTITY for item in value
|
||||
):
|
||||
inputs[key] = [File.model_validate(item) for item in value]
|
||||
return inputs
|
||||
|
@ -13,7 +13,7 @@ def test_file_loads_and_dumps():
|
||||
)
|
||||
|
||||
file_dict = file.model_dump()
|
||||
assert file_dict["model_identity"] == FILE_MODEL_IDENTITY
|
||||
assert file_dict["dify_model_identity"] == FILE_MODEL_IDENTITY
|
||||
assert file_dict["type"] == file.type.value
|
||||
assert isinstance(file_dict["type"], str)
|
||||
assert file_dict["transfer_method"] == file.transfer_method.value
|
||||
|
Loading…
x
Reference in New Issue
Block a user