Skip to content

Commit

Permalink
fix: inconsistent text table result for Message Type output, setting …
Browse files Browse the repository at this point in the history
…message.text as default status instead of Table as self.status (#6319)

* update message output to display only the text

* Update component.py

* Update component.py

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/custom/custom_component/component.py

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
  • Loading branch information
3 people authored Feb 13, 2025
1 parent a4a70d4 commit b38b6aa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/backend/base/langflow/custom/custom_component/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,17 +981,23 @@ def _build_artifact(self, result):
return {"repr": custom_repr, "raw": raw, "type": artifact_type}

def _process_raw_result(self, result):
if len(self.outputs) == 1:
return self.status or self.extract_data(result)
"""Process the raw result of the component."""
return self.extract_data(result)

def extract_data(self, result):
"""Extract the data from the result. this is where the self.status is set."""
if isinstance(result, Message):
self.status = result.get_text()
return (
self.status if self.status is not None else "No text available"
) # Provide a default message if .text_key is missing
if hasattr(result, "data"):
return result.data
if hasattr(result, "model_dump"):
return result.model_dump()
if isinstance(result, Data | dict | str):
return result.data if isinstance(result, Data) else result

if self.status:
return self.status
return result
Expand Down

0 comments on commit b38b6aa

Please sign in to comment.