return artifact values into log to frontend
This commit is contained in:
parent
b67ef6ea72
commit
d68e5a1143
3 changed files with 12 additions and 5 deletions
|
|
@ -171,7 +171,7 @@ async def build_vertex(
|
||||||
result_dict,
|
result_dict,
|
||||||
params,
|
params,
|
||||||
valid,
|
valid,
|
||||||
_,
|
artifacts,
|
||||||
vertex,
|
vertex,
|
||||||
) = await graph.build_vertex(
|
) = await graph.build_vertex(
|
||||||
lock=lock,
|
lock=lock,
|
||||||
|
|
@ -181,20 +181,22 @@ async def build_vertex(
|
||||||
inputs_dict=inputs.model_dump() if inputs else {},
|
inputs_dict=inputs.model_dump() if inputs else {},
|
||||||
files=files,
|
files=files,
|
||||||
)
|
)
|
||||||
|
log_obj = Log(message=vertex.artifacts_raw, type=vertex.artifacts_type)
|
||||||
result_data_response = ResultDataResponse(**result_dict.model_dump())
|
result_data_response = ResultDataResponse(**result_dict.model_dump())
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.exception(f"Error building vertex: {exc}")
|
logger.exception(f"Error building vertex: {exc}")
|
||||||
params = format_exception_message(exc)
|
params = format_exception_message(exc)
|
||||||
valid = False
|
valid = False
|
||||||
|
log_obj = Log(message=params, type="error")
|
||||||
result_data_response = ResultDataResponse(results={})
|
result_data_response = ResultDataResponse(results={})
|
||||||
artifacts = {}
|
artifacts = {}
|
||||||
# If there's an error building the vertex
|
# If there's an error building the vertex
|
||||||
# we need to clear the cache
|
# we need to clear the cache
|
||||||
await chat_service.clear_cache(flow_id_str)
|
await chat_service.clear_cache(flow_id_str)
|
||||||
|
|
||||||
log_object = Log(message=log_message)
|
result_data_response.message = artifacts
|
||||||
result_data_response.logs.append(log_object)
|
result_data_response.logs.append(log_obj)
|
||||||
|
|
||||||
# Log the vertex build
|
# Log the vertex build
|
||||||
if not vertex.will_stream:
|
if not vertex.will_stream:
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,8 @@ class VerticesOrderResponse(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class Log(TypedDict):
|
class Log(TypedDict):
|
||||||
message: str
|
message: Union[dict, str]
|
||||||
|
type: str
|
||||||
|
|
||||||
|
|
||||||
class ResultDataResponse(BaseModel):
|
class ResultDataResponse(BaseModel):
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any, AsyncIterator, Callable, Dict, Iterator,
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from langflow.graph.schema import INPUT_COMPONENTS, OUTPUT_COMPONENTS, InterfaceComponentTypes, ResultData
|
from langflow.graph.schema import INPUT_COMPONENTS, OUTPUT_COMPONENTS, InterfaceComponentTypes, ResultData
|
||||||
from langflow.graph.utils import UnbuiltObject, UnbuiltResult
|
from langflow.graph.utils import UnbuiltObject, UnbuiltResult, ArtifactType
|
||||||
from langflow.graph.vertex.utils import generate_result, log_transaction
|
from langflow.graph.vertex.utils import generate_result, log_transaction
|
||||||
from langflow.interface.initialize import loading
|
from langflow.interface.initialize import loading
|
||||||
from langflow.interface.listing import lazy_load_dict
|
from langflow.interface.listing import lazy_load_dict
|
||||||
|
|
@ -63,6 +63,8 @@ class Vertex:
|
||||||
self._built_result = None
|
self._built_result = None
|
||||||
self._built = False
|
self._built = False
|
||||||
self.artifacts: Dict[str, Any] = {}
|
self.artifacts: Dict[str, Any] = {}
|
||||||
|
self.artifacts_raw: Any = None
|
||||||
|
self.artifacts_type: Optional[str] = None
|
||||||
self.steps: List[Callable] = [self._build]
|
self.steps: List[Callable] = [self._build]
|
||||||
self.steps_ran: List[Callable] = []
|
self.steps_ran: List[Callable] = []
|
||||||
self.task_id: Optional[str] = None
|
self.task_id: Optional[str] = None
|
||||||
|
|
@ -648,6 +650,8 @@ class Vertex:
|
||||||
self._built_object, self.artifacts = result
|
self._built_object, self.artifacts = result
|
||||||
elif len(result) == 3:
|
elif len(result) == 3:
|
||||||
self._custom_component, self._built_object, self.artifacts = result
|
self._custom_component, self._built_object, self.artifacts = result
|
||||||
|
self.artifacts_raw = self.artifacts.pop("raw", None)
|
||||||
|
self.artifacts_type = self.artifacts.pop("type", None) or ArtifactType.UNKNOWN.value
|
||||||
else:
|
else:
|
||||||
self._built_object = result
|
self._built_object = result
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue