mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-09 04:49:26 +00:00
feat: Run AWEL flow in CLI (#1341)
This commit is contained in:
@@ -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]]]
|
||||
|
||||
|
@@ -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]):
|
||||
|
Reference in New Issue
Block a user