Convert json array to string

I’m building AI chatbots and having a hard time converting the LLM response into a message that I can send.

The LLM API response is inside an array with each word is a separate item. From what I understand this allows streaming but my setup just sends the completed message all at once.

What’s the best way to convert this into a simple block of text I can send as a message?

I don’t know if I should text parse the array and remove commas. I’ve tried an iterator module followed by an array aggregator but tbh I just get repeats of the same message with all the commas. Any help is hugely appreciated!!

Sample output

“output”: [
“Hey”,
" there",
“.”
“”
]

i think the join() function should help you out here

2 Likes

Thanks, that’s definitely moving in the right direction but something is still missing…

Here’s my starting array:

“output”: [
" The",
" capital",
" of",
" the",
" United",
" States",
" is",
" Washington",
“,”,
" D",
“.”,
“C”,
“.”,
" I",
“'”,
“m”,
" glad",
" to",
" help",
" you",
" with",
" any",
" other",
" questions",
" you",
" may",
" have",
“!”,
“”
]

I used the join function in the tools module. Formula is: join(output; )

The output string is this:

    "joinedText": " The, capital, of, the, United, States, is, Washington,,, D,.,C,., I,',m, glad, to, help, you, with, any, other, questions, you, may, have,!,"

So it’s creating the string, but not taking out the commas. Is it just a matter of using a text parser or is there a better way to remove the commas along with string creation? I’d think it wouldn’t include those since they’re just separators.

Hello @Alan3,
I belive if you use join() without specifying the separator, it’s going to default to comma, which is what you’re getting.
Try using {{emptystring}} after the semi-colon in the join function, like this:

join(output;{{emptystring}})

2 Likes

Thanks. I guess the issue was that I was typing in join instead of using the join tag from the tools module.

2 Likes