How to pass secret keys to exported flow that is triggered using Python ? #3692
-
I exported my flow as
When I run this script, I get an error, saying
I understand the problem that its not able to see / load the secret strings used in flow. In flow I used Global variable to save and use secret strings (different API keys). When I use the flow like this in Python, how can I pass the secrets to flow so that all the components in flow that need secrets get it as expected ? I read here that the global variables used are actually stored in DB used by langflow. There seems to be some way (also explained on the same page) to override the variables and pass them through .env file, but I could not understand it well. If anyone know how to do it, please share some working examples of passing global variables values through .env or any other way from python program.. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hey there, @gauravdhiman! I'm here to help you with any bugs or questions you have while waiting for a human maintainer. Let's tackle this together! To pass secret keys to an exported flow triggered using Python and ensure that all components in the flow receive the necessary secrets, you can use environment variables. Here are examples of how to pass global variable values through a Using a
|
Beta Was this translation helpful? Give feedback.
-
On digging in code found that we can pass the API keys through Tweak object that we pass --OR-- explicitly set Either of these approaches should work. I tried the first one (passing it using Tweak and it worked. Here is the tweak object that I passed and worked for me. Imp think to note here is also that we need to set
|
Beta Was this translation helpful? Give feedback.
-
Hey @gauravdhiman Please, make sure you rotate this API key you exposed here. |
Beta Was this translation helpful? Give feedback.
On digging in code found that we can pass the API keys through Tweak object that we pass --OR-- explicitly set
fallback_to_env_vars
parameter toTrue
while callingrun_flow_from_json()
and pass the path to .env file inenv
parameter.Either of these approaches should work. I tried the first one (passing it using Tweak and it worked. Here is the tweak object that I passed and worked for me. Imp think to note here is also that we need to set
load_from_db
key asFalse
, else langflow will look into DB not in tweak.