Hello everyone; I’m trying to use AIP Logic to work with an array of outputs from an LLM call and am having a tough time of it.
My Use LLM block looks like this; it’s generating several items and returning them in an Array<Struct>, but I cannot seem to find a way to loop over that array in AIP Logic and create an ontology item for each response.
My next attempt was to work around this by making a TypeScript Function in Code Repositories that accepted an object[], but similarly, it looks like AIP Logic cannot call functions that make ontology edits.
This is making me think that AIP Logic is really designed for pipelines that create a single scalar output (like the text of an email to a customer) and create one or more ontology objects from that scalar value.
Am I missing something obvious here? How would you go about working with arrays of structured output if not in AIP Logic?
On first glance the best way to do this would be to call the logic function inside of a typescript function instead of trying to call the typescript function inside of the logic function.
Basically, you would be using the logic function as a subroutine in your typescript function and call it in a loop to generate your objects.
The way you would do this is using Queries, docs here.
My Use LLM block looks like this; it’s generating several items and returning them in an Array<Struct> ,
Have you blanked out the field names for the purposes of not leaking information about your use case or are does the real function use “…”?
If it does you might want something like Array here.
I cannot seem to find a way to loop over that array in AIP Logic and create an ontology item for each response.
Yes, you aren’t missing anything, this is a big gap in Logic right now. We are working on exactly this feature (being able to loop over an array to do ontology edits / several blocks) right now though and it should be available soon.
In the meantime your intuition was right:
making a TypeScript Function in Code Repositories that accepted an object[] , but similarly, it looks like AIP Logic cannot call functions that make ontology edits.
All you need to do is first wrap that function in an Action. Then Logic will be able to call it to edit your ontology.