mirror of
https://github.com/vegu-ai/talemate.git
synced 2025-09-02 02:19:12 +00:00
fix issue with Split and Join nodes when passed \n as delimiter
This commit is contained in:
parent
fbc2cdbe14
commit
4f03811f6f
1 changed files with 9 additions and 1 deletions
|
@ -108,10 +108,14 @@ class Split(Node):
|
||||||
self.set_property("max_splits", -1)
|
self.set_property("max_splits", -1)
|
||||||
|
|
||||||
async def run(self, state: GraphState):
|
async def run(self, state: GraphState):
|
||||||
string = self.get_input_value("string")
|
string:str = self.get_input_value("string")
|
||||||
delimiter = self.get_input_value("delimiter")
|
delimiter = self.get_input_value("delimiter")
|
||||||
max_splits = self.get_property("max_splits")
|
max_splits = self.get_property("max_splits")
|
||||||
|
|
||||||
|
# handle escaped newline delimiter
|
||||||
|
if delimiter == "\\n":
|
||||||
|
delimiter = "\n"
|
||||||
|
|
||||||
parts = string.split(delimiter, maxsplit=max_splits)
|
parts = string.split(delimiter, maxsplit=max_splits)
|
||||||
self.set_output_values({"parts": parts})
|
self.set_output_values({"parts": parts})
|
||||||
|
|
||||||
|
@ -154,6 +158,10 @@ class Join(Node):
|
||||||
strings = self.get_input_value("strings")
|
strings = self.get_input_value("strings")
|
||||||
delimiter = self.get_input_value("delimiter")
|
delimiter = self.get_input_value("delimiter")
|
||||||
|
|
||||||
|
# handle escaped newline delimiter
|
||||||
|
if delimiter == "\\n":
|
||||||
|
delimiter = "\n"
|
||||||
|
|
||||||
if not all(isinstance(s, str) for s in strings):
|
if not all(isinstance(s, str) for s in strings):
|
||||||
raise InputValueError(self, "strings", "All items must be strings")
|
raise InputValueError(self, "strings", "All items must be strings")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue