langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Make API keys discoverable from environment variables

Open ogabrielluiz opened this issue 2 years ago β€’ 8 comments

Backend should check for necessary environment variables and set them up on the nodes that require them.

Probably a better way would simply acknowledge that the keys are present and use them when the chat request arrives.

ogabrielluiz avatar Mar 15 '23 00:03 ogabrielluiz

@ogabrielluiz is this something one can do today? tried setting OPENAI_API_KEY as an env, with no success

FilipByren avatar Apr 15 '23 15:04 FilipByren

I think I can work on that right away. It was possible but we made some changes lately that might have changed that.

ogabrielluiz avatar Apr 17 '23 17:04 ogabrielluiz

Has this affected the solution you showed for Azure OpenAI here: #85 ? Trying to make that work and not clear on how I should be doing it.

TheodorosGalanos avatar Apr 18 '23 01:04 TheodorosGalanos

Thank you @ogabrielluiz let me know when it’s live and how I should setup everything, so the user do not need to setup the openai keys πŸ™πŸ‘Œ

FilipByren avatar Apr 18 '23 06:04 FilipByren

@ogabrielluiz Is this something I can help an contribute to by ex. loading from a .envfile and checking optionally for ENV variables in the UI components for if the variables are already defined?

MarkusSagen avatar Apr 25 '23 14:04 MarkusSagen

Hey, @MarkusSagen. This could be a good approach. LangChain already checks for them in the background if left empty but currently, we process it in a way that does not allow LangChain to do that.

What would be your plan? load the .env in the main and then in the frontend get the value from the environment and put it in the node by default?

ogabrielluiz avatar Apr 25 '23 14:04 ogabrielluiz

I think I got it working in the branch https://github.com/logspace-ai/langflow/tree/20-make-api-keys-discoverable-from-environment-variables

ogabrielluiz avatar Apr 25 '23 14:04 ogabrielluiz

Thank for the fix @MarkusSagen and @ogabrielluiz

FilipByren avatar Apr 25 '23 17:04 FilipByren

what's the necessary format for the .env?

ngmisl avatar Apr 28 '23 13:04 ngmisl

The .env isn't loaded by LangFlow, you'd have to set the variable in your environment.

We can create an issue to implement that at some point.

ogabrielluiz avatar Apr 28 '23 13:04 ogabrielluiz