FlowiseAI / Flowise

Drag & drop UI to build your customized LLM flow
https://flowiseai.com
Apache License 2.0
29.72k stars 15.32k forks source link

Is there a way to pass variables to System Prompt via an api call for Conversational Retrieval QA Chain or Tool Agent or Conversation Chain? #2991

Closed vijaykammili closed 1 week ago

vijaykammili commented 1 month ago

@HenryHengZJ How can i pass variables to the System Prompt via the API?

image

I know the following works for nodes that have promptValues defined like Chat Prompt Template. Is there something like this for Conversational Retrieval QA Chain or Tool Agent or Conversation Chain? Trying to find a way so I don't have to override the whole system prompt and just pass the variables necessary.

{"question": "Hi", "overrideConfig": { "promptValues": { "input_language": "French", "output_language": "Italian" } } }

HenryHengZJ commented 1 month ago

Just added a PR for that https://github.com/FlowiseAI/Flowise/pull/2986

vijaykammili commented 1 month ago

Fantastic! Thanks a lot, @HenryHengZJ

vijaykammili commented 1 month ago

@HenryHengZJ: This works when you send the variables for the 1st turn but doesn't work for the subsequent turns.

Here is an example:

1st Turn:

Input Payload:

{ "question": "Hello", "overrideConfig": { "sessionId": "88880", "vars" : { "date": "Jun 4 2024" } } }

Output: Jun 4 2024

2nd Turn

Input Payload:

{ "question": "Hello", "overrideConfig": { "sessionId": "88880", "vars" : { "date": "Jun 5 2024" } } }

Output: Jun 4 2024

image

Also, does this work for Tool Agent?

HenryHengZJ commented 3 weeks ago

@vijaykammili in your case, you will need to turn off the cache: DISABLE_CHATFLOW_REUSE https://docs.flowiseai.com/configuration/environment-variables

vijaykammili commented 3 weeks ago

@HenryHengZJ - Thank you. I tried to turn off cache and I still have the same issue.

HenryHengZJ commented 3 weeks ago

does it work if you try a simple conversation chain? image

vijaykammili commented 3 weeks ago

@HenryHengZJ - Nope. It doesn't. I tested it with a conversation chain.

schieck0 commented 3 weeks ago

Same problem here, I can't pass a variable through the API. I tried type static and runtime, but the value doesn't change. image image

HenryHengZJ commented 1 week ago

Im not sure why but it works for me.

1.) 1st request: image

2.) 2nd request: image

using a simple flow: image image

vijaykammili commented 1 week ago

@HenryHengZJ - I tested this again today on version 2.0.7 for Conversation Chain, Tool agent and Conversational Retrieval QA Chain and this is working as expected. Not sure what changed but glad it's working. Thank you.

vijaykammili commented 1 week ago

@HenryHengZJ - I've done some additional testing. Is there a limit to the number of variables you can pass via the API? some of the variables don't get passed, it's very inconsistent. Tested with Simple Conversation Chain, Tool Agent and Conv QA Retrieval Chain.

image image
HenryHengZJ commented 1 week ago

@vijaykammili good spot! put up a bugfix here: https://github.com/FlowiseAI/Flowise/pull/3129