fix(workflow): fix streaming output parsing errors and improve file-type output handling
This commit is contained in:
@@ -667,6 +667,15 @@ class BaseNode(ABC):
|
||||
|
||||
@staticmethod
|
||||
def process_model_output(content) -> str:
|
||||
if isinstance(content, dict):
|
||||
return content.get("text")
|
||||
return content
|
||||
result = ""
|
||||
if isinstance(content, list):
|
||||
for msg in content:
|
||||
if isinstance(msg, dict):
|
||||
result += msg.get("text")
|
||||
elif isinstance(msg, str):
|
||||
result += msg
|
||||
elif isinstance(content, dict):
|
||||
result = content.get("text")
|
||||
elif isinstance(content, str):
|
||||
return content
|
||||
return result
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Any, TypeVar, Type, Generic
|
||||
|
||||
from deprecated import deprecated
|
||||
|
||||
from app.core.workflow.variable.base_variable import BaseVariable, VariableType, FileObject
|
||||
from app.core.workflow.variable.base_variable import BaseVariable, VariableType, FileObject, FileType
|
||||
|
||||
T = TypeVar("T", bound=BaseVariable)
|
||||
|
||||
@@ -75,7 +75,7 @@ class FileVariable(BaseVariable):
|
||||
raise TypeError(f"Value must be a FileObject - {type(value)}:{value}")
|
||||
|
||||
def to_literal(self) -> str:
|
||||
return str(self.value.model_dump())
|
||||
return f'{"!"if self.value.type == FileType.IMAGE else ""}[file]({self.value.url})'
|
||||
|
||||
def get_value(self) -> Any:
|
||||
return self.value.model_dump()
|
||||
|
||||
Reference in New Issue
Block a user