mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-01 08:11:45 +00:00
fix(awel): Fix awel check empty data bug (#1311)
This commit is contained in:
parent
4970c9f813
commit
86a7b6c6f3
@ -33,6 +33,19 @@ class _EMPTY_DATA_TYPE:
|
||||
def __str__(self):
|
||||
return f"EmptyData({self.name})"
|
||||
|
||||
def is_same(self, obj: Any) -> bool:
|
||||
"""Check if the object is the same as the current object.
|
||||
|
||||
Args:
|
||||
obj (Any): The object to compare with.
|
||||
|
||||
Returns:
|
||||
bool: True if the object is the same as the current object, False otherwise.
|
||||
"""
|
||||
if not isinstance(obj, _EMPTY_DATA_TYPE):
|
||||
return False
|
||||
return self == obj
|
||||
|
||||
|
||||
EMPTY_DATA = _EMPTY_DATA_TYPE("EMPTY_DATA")
|
||||
SKIP_DATA = _EMPTY_DATA_TYPE("SKIP_DATA")
|
||||
|
@ -76,7 +76,7 @@ class SimpleTaskOutput(TaskOutput[T], Generic[T]):
|
||||
@property
|
||||
def output(self) -> T:
|
||||
"""Return the output data."""
|
||||
if self._data == EMPTY_DATA:
|
||||
if EMPTY_DATA.is_same(self._data):
|
||||
raise ValueError("No output data for current task output")
|
||||
return cast(T, self._data)
|
||||
|
||||
@ -188,7 +188,7 @@ class SimpleStreamTaskOutput(TaskOutput[T], Generic[T]):
|
||||
Raises:
|
||||
ValueError: If the output data is empty.
|
||||
"""
|
||||
if self._data == EMPTY_DATA:
|
||||
if EMPTY_DATA.is_same(self._data):
|
||||
raise ValueError("No output data for current task output")
|
||||
return cast(AsyncIterator[T], self._data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user