typebot.io icon indicating copy to clipboard operation
typebot.io copied to clipboard

Add array type in Generate variables action

Open baptisteArno opened this issue 1 year ago • 5 comments

Image

baptisteArno avatar Nov 03 '24 17:11 baptisteArno

any workaround for the time being? @baptisteArno

andreanicassio avatar Dec 03 '24 22:12 andreanicassio

The workaround is to use the Create chat completion action and try to trick it into providing a JSON result

baptisteArno avatar Dec 04 '24 07:12 baptisteArno

@baptisteArno @andreanicassio the method I've found is to get the OpenAI Assistant to give the result in the form of a list with the elements separated by a comma with no spaces by giving it a precise example of the type of result it should give and then to run a script immediately afterwards to format it as an array.

It's not comfortable, I'd like to be able to generate an array directly. If you think there's something better than my method, let me know here. I've struggled with this problem.

const sujetsGeneration = {{sujets_generation}};

if (sujetsGeneration) {
  const sujetsArray = sujetsGeneration.split(',').map(sujet => sujet.trim());
  setVariable('sujets_proposition', sujetsArray);
} else {
  setVariable('sujets_proposition', []);
}

bst1n avatar Dec 04 '24 08:12 bst1n

Yes that’s similar to the workaround I used. I just put in the description of the variable to add values separated by semicolon and then do the split with scripting.

On Wed, 4 Dec 2024 at 09:26, Bastien @.***> wrote:

@baptisteArno https://github.com/baptisteArno @andreanicassio https://github.com/andreanicassio the method I've found is to get the OpenAI Assistant to give the result in the form of a list with the elements separated by a comma with no spaces by giving it a precise example of the type of result it should give and then to run a script immediately afterwards to format it as a list.

It's not comfortable, I'd like to be able to generate an array directly. If you think there's something better than my method, let me know here. I've struggled with this problem.

const sujetsGeneration = {{sujets_generation}};

if (sujetsGeneration) { const sujetsArray = sujetsGeneration.split(',').map(sujet => sujet.trim()); setVariable('sujets_proposition', sujetsArray); } else { setVariable('sujets_proposition', []); }

— Reply to this email directly, view it on GitHub https://github.com/baptisteArno/typebot.io/issues/1870#issuecomment-2516526051, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLDZ73IC4PTJHB2YFOR2L4L2D24B3AVCNFSM6AAAAABRC5TOGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJWGUZDMMBVGE . You are receiving this because you were mentioned.Message ID: @.***>

andreanicassio avatar Dec 04 '24 11:12 andreanicassio

Can you share your script @andreanicassio so that I understand ? Maybe your solution is better than mine

bst1n avatar Dec 07 '24 14:12 bst1n