unified vertex log creation
This commit is contained in:
parent
1912f91139
commit
bfee5a508f
4 changed files with 12 additions and 19 deletions
|
|
@ -149,7 +149,6 @@ async def build_vertex(
|
|||
|
||||
next_runnable_vertices = []
|
||||
top_level_vertices = []
|
||||
logs = {}
|
||||
try:
|
||||
start_time = time.perf_counter()
|
||||
cache = await chat_service.get_cache(flow_id_str)
|
||||
|
|
@ -189,15 +188,13 @@ async def build_vertex(
|
|||
valid = False
|
||||
output_label = vertex.outputs[0]["name"] if vertex.outputs else "output"
|
||||
logs = {output_label: [Log(message=params, type="error")]}
|
||||
result_data_response = ResultDataResponse(results={})
|
||||
result_data_response = ResultDataResponse(results={}, logs=logs)
|
||||
artifacts = {}
|
||||
# If there's an error building the vertex
|
||||
# we need to clear the cache
|
||||
await chat_service.clear_cache(flow_id_str)
|
||||
|
||||
result_data_response.message = artifacts
|
||||
if logs:
|
||||
result_data_response.logs = logs
|
||||
|
||||
# Log the vertex build
|
||||
if not vertex.will_stream:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from langflow.graph.utils import UnbuiltObject, UnbuiltResult
|
|||
from langflow.interface.initialize import loading
|
||||
from langflow.interface.listing import lazy_load_dict
|
||||
from langflow.schema.artifact import ArtifactType
|
||||
from langflow.schema.schema import INPUT_FIELD_NAME, Log, build_log_from_raw_and_type
|
||||
from langflow.schema.schema import INPUT_FIELD_NAME, Log, build_logs
|
||||
from langflow.services.deps import get_storage_service
|
||||
from langflow.services.monitor.utils import log_transaction
|
||||
from langflow.utils.constants import DIRECT_TYPES
|
||||
|
|
@ -113,6 +113,8 @@ class Vertex:
|
|||
self.build_times.append(time)
|
||||
|
||||
def set_result(self, result: ResultData) -> None:
|
||||
from pprint import pprint
|
||||
pprint(result.model_dump())
|
||||
self.result = result
|
||||
|
||||
def get_built_result(self):
|
||||
|
|
@ -658,13 +660,11 @@ class Vertex:
|
|||
if len(result) == 2:
|
||||
self._built_object, self.artifacts = result
|
||||
elif len(result) == 3:
|
||||
import pdb; pdb.set_trace()
|
||||
self._custom_component, self._built_object, self.artifacts = result
|
||||
self.artifacts_raw = self.artifacts.get("raw", None)
|
||||
self.artifacts_type = self.artifacts.get("type", None) or ArtifactType.UNKNOWN.value
|
||||
self.logs[self.outputs[0]["name"]] = build_log_from_raw_and_type(
|
||||
self.artifacts_raw, self.artifacts_type
|
||||
)
|
||||
|
||||
self.logs = build_log(self)
|
||||
else:
|
||||
self._built_object = result
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from langflow.graph.utils import UnbuiltObject, serialize_field
|
|||
from langflow.graph.vertex.base import Vertex
|
||||
from langflow.schema import Data
|
||||
from langflow.schema.artifact import ArtifactType
|
||||
from langflow.schema.schema import INPUT_FIELD_NAME, build_logs_from_artifacts
|
||||
from langflow.schema.schema import INPUT_FIELD_NAME, build_logs
|
||||
from langflow.services.monitor.utils import log_transaction, log_vertex_build
|
||||
from langflow.utils.schemas import ChatOutputResponse, DataOutputResponse
|
||||
from langflow.utils.util import unescape_string
|
||||
|
|
@ -48,7 +48,7 @@ class ComponentVertex(Vertex):
|
|||
for key in self.artifacts:
|
||||
self.artifacts_raw[key] = self.artifacts[key].get("raw", None)
|
||||
self.artifacts_type[key] = self.artifacts[key].get("type", None) or ArtifactType.UNKNOWN.value
|
||||
self.logs = build_logs_from_artifacts(self.artifacts)
|
||||
self.logs = build_logs(self)
|
||||
else:
|
||||
self._built_object = result
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ class Log(TypedDict):
|
|||
type: str
|
||||
|
||||
|
||||
def build_logs_from_artifacts(artifacts: dict) -> dict:
|
||||
def build_logs(vertex) -> dict:
|
||||
logs = {}
|
||||
for key in artifacts:
|
||||
message = artifacts[key]["raw"]
|
||||
_type = artifacts[key]["type"]
|
||||
for key in vertex.artifacts:
|
||||
message = vertex.artifacts[key]["raw"]
|
||||
_type = vertex.artifacts[key]["type"]
|
||||
|
||||
if "stream_url" in message and "type" in message:
|
||||
stream_url = StreamURL(location=message["stream_url"])
|
||||
|
|
@ -31,7 +31,3 @@ def build_logs_from_artifacts(artifacts: dict) -> dict:
|
|||
|
||||
logs[key] = [log]
|
||||
return logs
|
||||
|
||||
|
||||
def build_log_from_raw_and_type(raw: Any, log_type: str) -> Log:
|
||||
return Log(message=raw, type=log_type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue