https://discord.gg/botpress logo
Re-use autonomous node generated code
# 🤝help
b
When we use autonomous nodes in our workflows, it seems that every time the node is transitioned to, the LLM generates new code that gets executed. This means that we're adding 1-5 seconds per autonomous node, which is a noticeable lag for our users. If the autonomous node is doing a very deterministic task then it makes sense that we would be able to re-use its outputted code and not generate this every time. However, I haven't been able yet to find a way to use the outputted JSX code in a non-autonomous node. Is this possible? For example, how would I get my bot to display the following JSX every time, without it needing to be re-generated on the fly? yield {conversation.uncompletedItems.map(nudge => ( <Button key={item.id} action="postback" label={item.label} value={item.label} /> ))} Or, is there a way to tell an autonomous node to re-use its output and never re-generate the code after the first time?
l
There is currently no built‑in options to cache that generated code or tell the node to reuse it.
However have you tried using Actions?
They are code snippets that can be called from any autonomous node and are re‑usable
And if you want to display the same snippet everytime could you also just use a standard node?
b
Thanks for the response, I will look into Actions and whether they allow us this functionality. I think mainly I'm looking for a way to display my own JSX using a standard node. Then I could just copy over an autonomous node's output code which would then display every time. Do you know if it's possible to achieve this in an Execute Code card or similar?
w
hey, you could use a hook
'after llmz execution"
use ⁨`const code = execution.iterations[0].llm.output`⁩
it'll give something like this : ⁨```■fn_start // Greeting the user warmly and .. yield return { action: 'listen' }```⁩
and then you can store that in a workflow variable and reuse the code
but take care of removing the ■fn_start and potential ■fn_end
b
Ooh thanks @wooden-beard-40210 this looks like a creative solution that might allow this to work!
4 Views