https://discord.gg/botpress logo
How do I change the LLM for each
# 🌎general
m
How do I change the LLM for each autonomous node? I know using hooks but how??
p
So here are the steps: 1. Create a before LLMZ execution hook 2. Find the nodes and workflows in which the model should be changed, their id/names can be found in the event.state.context object 3. Find the llm model you'd like to use, you can do this by changing the model to your desired one and logging it (as per the code below) or looking at the whole list via context.options.models.model The final code should look similar to this:
Copy code
js
const isMainFlow = event.state.context.currentFlow.includes('main')  //<--- The flow location
const isOrchestrator = event.state.context.currentNode.includes('1e9baaf49d') //<-- the node id
console.log('Current Model: ', context.model) <-- console log the id name of the LLM to know what to use in the next block
  if (isMainFlow && isOrchestrator) { //if flow equals the flow your AN is in AND the NodeID matches the AN you want to change the LLM for
    context.model = 'openai__gpt-4.1-2025-04-14' // change the LLM model to the LLM id you want
    console.log('New Model: ', context.model) // console log the result to see if it applied
  }
Hope thsi helsp!
m
Cool, Thanks @prehistoric-airplane-85682
p
No worries, Happy to help!