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

[BUG] - Update variable using a custom tool don't work #2968

Open
alziromoraes opened this issue Aug 7, 2024 · 5 comments
Open

[BUG] - Update variable using a custom tool don't work #2968

alziromoraes opened this issue Aug 7, 2024 · 5 comments
Labels
question Further information is requested

Comments

@alziromoraes
Copy link

Describe the bug
I created a variable and I need to change its value during the flow with api callback. Using $vars.VariableName does not change the value stored for the variable in other calls.

Expected behavior
The variable value should be updated and persisted in the database

Setup

  • Installation docker
  • Flowise Version 1.8.2
  • OS: Linux

How can I update the values ​​of these variables?

@danieldabate
Copy link
Contributor

I don't think this is a bug, variables are not supposed to be modified and persisted across flow calls.

Could you explain your use case? Maybe it can be solved in another way.

@alziromoraes
Copy link
Author

alziromoraes commented Aug 8, 2024

To connect to an external API I need to request a token, which has an expiration date, to send in all requests. I need to check the expiration to request a new token and I cannot always request a new token due to limit issues from the API provider.

I thought about storing the token and the expiration date in variables so I can check it in the custom tool.

Another thing I need is to be able to place this verification code in a separate function because I will have to call it in several custom tools and I have already tried several ways without success.

My installation is using postgreSQL and I created code to query and test the information but repeating this code in all custom tools is bad for maintaining the code.

Tks

@danieldabate
Copy link
Contributor

About the repeating code, you can have a custom tool that retrieves the token, storing it/retrieving it from a cache if necessary. The agent would have to use it every time it needs to call a tool.

There are a few alternatives here, depending on your infrastructure setup. One alternative is to store the token in a file in disk, but that will only work well if you have one replica of Flowise running and you have persistent storage.

Another way is using an external database or storage. S3, DynamoDB, etc. might work. You might event be able to store it in the same Postgres instance you are using for Flowise.

I know that this is more work than just changing a variable, but it's the only solution I can think of atm.

Let's see what others think.

@HenryHengZJ
Copy link
Contributor

You can pass it here: https://docs.flowiseai.com/integrations/langchain/tools/custom-tool#pass-variables-to-function

"overrideConfig": {
        "vars": {
            "apiKey": "abc"
        }
    }

@HenryHengZJ HenryHengZJ added the question Further information is requested label Aug 9, 2024
@schieck0
Copy link

As mentioned here, I also cannot set a value in variables using the API.
#2991 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants