fix: expose api text output in comfy history
This commit is contained in:
+3
-2
@@ -18,5 +18,6 @@ class ApiTextOutputNode:
|
||||
CATEGORY = "Fast Preview"
|
||||
|
||||
def send_text_to_api(self, text):
|
||||
print(f"[Fast Preview] Sending text string to API payload: {text}")
|
||||
return (text, {"ui": {"text": [text]}})
|
||||
text_value = str(text)
|
||||
print(f"[Fast Preview] Sending text string to API payload: {text_value}")
|
||||
return {"ui": {"text": [text_value]}, "result": (text_value,)}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
|
||||
from api_text_node import ApiTextOutputNode
|
||||
|
||||
|
||||
class ApiTextOutputNodeTest(unittest.TestCase):
|
||||
def test_returns_comfy_ui_and_result_payload(self):
|
||||
payload = ApiTextOutputNode().send_text_to_api("blue cotton shirt")
|
||||
|
||||
self.assertEqual(payload["ui"]["text"], ["blue cotton shirt"])
|
||||
self.assertEqual(payload["result"], ("blue cotton shirt",))
|
||||
|
||||
def test_coerces_non_string_values(self):
|
||||
payload = ApiTextOutputNode().send_text_to_api(42)
|
||||
|
||||
self.assertEqual(payload["ui"]["text"], ["42"])
|
||||
self.assertEqual(payload["result"], ("42",))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user