AIP Logic Function and Workshop

I am trying to prompt an LLM from AIP logic with an input from a Workshop page. I want the output of the LLM to be separated into two dynamic string selectors. Is there a way for the LLM to create two arrays in one call and separate them into two outputs? How do I set the output of the LLM in Workshop to be a string array and have that be an input of the string selector? I would greatly appreciate any help here, thanks.

Hey,

To clarify, your AIP Logic function accepts what type of input? A string? This can be the string output variable from the Text Input widget in Workshop and passed in as the input argument for your AIP Logic Function.

Your AIP Logic function can return an Array of Arrays output (with two elements). Split this up into two dedicated Use LLM blocks, each of which outputs one of the Array of Strings with the values for your dropdowns.

Then, search for the Create array block where you can pass in the arrays returned by the two LLM blocks above. This should be your AIP Logic function’s output.

You can then bring it into Workshop and it will return both arrays inside of an array. You may then need to use a TypeScript function like the one below to extract each array and store them in separate String Array variables. They can then be used in your String Selector widgets to populate the options in the dropdown.

import { Function, Integer } from "@foundry/functions-api";

export class MyFunctions {

    @Function()
    public getArrayAtIndex(
        nestedArrays: Array<Array<string>>,
        element: Integer
    ): Array<string> {
        return nestedArrays[element]; // 0-based indexing
    }

}
1 Like