feat: Run AWEL flow in CLI (#1341)

This commit is contained in:
Fangyin Cheng
2024-03-27 12:50:05 +08:00
committed by GitHub
parent 340a9fbc35
commit 3a7a2cbbb8
42 changed files with 1454 additions and 422 deletions

View File

@@ -161,6 +161,7 @@ class ModelOutput:
error_code: int
"""The error code of the model inference. If the model inference is successful,
the error code is 0."""
incremental: bool = False
model_context: Optional[Dict] = None
finish_reason: Optional[str] = None
usage: Optional[Dict[str, Any]] = None
@@ -171,6 +172,11 @@ class ModelOutput:
"""Convert the model output to dict."""
return asdict(self)
@property
def success(self) -> bool:
"""Check if the model inference is successful."""
return self.error_code == 0
_ModelMessageType = Union[List[ModelMessage], List[Dict[str, Any]]]

View File

@@ -470,6 +470,8 @@ class CommonStreamingOutputOperator(TransformStreamAbsOperator[ModelOutput, str]
Transform model output to the string output to show in DB-GPT chat flow page.
"""
output_format = "SSE"
metadata = ViewMetadata(
label=_("Common Streaming Output Operator"),
name="common_streaming_output_operator",
@@ -510,8 +512,8 @@ class CommonStreamingOutputOperator(TransformStreamAbsOperator[ModelOutput, str]
yield f"data:{error_msg}"
return
decoded_unicode = model_output.text.replace("\ufffd", "")
msg = decoded_unicode.replace("\n", "\\n")
yield f"data:{msg}\n\n"
# msg = decoded_unicode.replace("\n", "\\n")
yield f"data:{decoded_unicode}\n\n"
class StringOutput2ModelOutputOperator(MapOperator[str, ModelOutput]):