Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 opened this issue Aug 10, 2024 · 12 comments · Fixed by #3129
Labels
enhancement New feature or request in-work Issue in work

Comments

@vijaykammili
Copy link
Contributor

@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
Copy link
Contributor

Just added a PR for that #2986

@vijaykammili
Copy link
Contributor Author

Fantastic! Thanks a lot, @HenryHengZJ

@vijaykammili
Copy link
Contributor Author

@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
Copy link
Contributor

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

@HenryHengZJ HenryHengZJ added enhancement New feature or request in-work Issue in work labels Aug 17, 2024
@vijaykammili
Copy link
Contributor Author

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

@HenryHengZJ
Copy link
Contributor

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

@vijaykammili
Copy link
Contributor Author

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

@schieck0
Copy link

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
Copy link
Contributor

HenryHengZJ commented Aug 31, 2024

Im not sure why but it works for me.

1.) 1st request:
image

2.) 2nd request:
image

using a simple flow:
image
image

@vijaykammili
Copy link
Contributor Author

@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
Copy link
Contributor Author

@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

@vijaykammili vijaykammili reopened this Sep 2, 2024
@HenryHengZJ HenryHengZJ linked a pull request Sep 2, 2024 that will close this issue
@HenryHengZJ
Copy link
Contributor

@vijaykammili good spot! put up a bugfix here: #3129

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in-work Issue in work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants