Same flow but different System prompts

Hello everyone,

I have a complex workflow that begins with a webhook. Within this webhook, users can select a “flavor” option. The only difference between these flavors is that they use the same workflow but require different system prompts and AI models. Changing the AI model is straightforward using an expression, but the system prompt is a large block of text.

Where should I store these system prompts, and how can I select the appropriate one based on the chosen flavor? Currently, I have about 10 AI agent nodes that I switch between depending on the selected flavor. each one has it is own System prompt

You could employ the Switch node + respective Set nodes per each branch to define the prompt, all then converging into the same AI Agent or whatever other pre-processing node you need.

The other, less obvious to other possible workflow maintainers tho, option would be a Code node that would cover prompt definition based on flavor.

Prompts could be stored as scalar values or read from an external source.

If the above addresses your question, please mark this post as a :white_check_mark: Solution.

Thank you for the answer, I am already employing a Switch node so after it I know all the info needed to go into the AI Agent Node. the only issue now I have from every switch case an AI agent node and the only difference is the system prompt. can you elaborate more about external source ?

If you share your workflow it will be easier to come up with the suggestions and not shooting blind.
Please post it using the </> button.

this is a minified version and all of them linked to a response web hook

In this scenario, why having system prompts in every AI Agent node is not an option?

Your initial ask referred to using an expression to define a model per flavor, which, to me, implied you want one AI Agent node to serve them all.

it is an option but I dont like it feels redundant, Imagine having 15 of them.

Then why resorting to it?
Build a workflow as described in your initial ask, publish it and let’s take it from there.

Just in case you missed the suggestions past ‘+’ character in this post:

Thank you, I will use code block to add system_prompt after the switch will post the final solution when it is ready

here is the final solution, at the end i didnt even need the switch i did it in code block

const p1 = `this is flavor 1 prompt`;
const p2 = `this is flavor 2 prompt`;
const p3 = `this is flavor 3 prompt`;

for (const item of $input.all()) {
  if (item.json.flavor.toLowerCase() === "flavor1") {
    item.json.system_prompt = p1
  } else if (item.json.flavor.toLowerCase() === "flavor1") {
     item.json.system_prompt = p2
  } else if (item.json.flavor.toLowerCase() === "flavor2") {
    item.json.system_prompt = p3
  }
}

return $input.all();

I am stil interested to fetch this prompts from external system, but this should work for now

Congrats!

Although I’m not sure if you read responses deep enough.

The other, less obvious to other possible workflow maintainers tho, option would be a Code node that would cover prompt definition based on flavor.

It’s not so much about recognition, but more about if it is worth to invest time into writing more than a single sentence in response to your ask.

Sorry, to break it down to you like this.

Use a key-value storage, where key would be flavor and value would be prompt. Google Sheets is one of the options.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.