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] API KEY is not extracted from environment variables during connection creation with promptflow 1.10.1 #3236

Open
AlexTeslenko opened this issue May 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@AlexTeslenko
Copy link

Describe the bug
If Azure OpenAI API KEY is set as environment variable, and in connection yaml file it is set to get this value from environment variables, the value is not set during connection creation and it leads to failed running flow.

How To Reproduce the bug

  1. Set AOAI_API_KEY as environment variable
  2. Create connection yaml file with api_key taken from env variables:
$schema: 
  https://azuremlschemas.azureedge.net/promptflow/latest/AzureOpenAIConnection.schema.json
type: azure_open_ai
name: aoai
module: promptflow.connections
api_base: https://teslenkoopenairesource.openai.azure.com/
api_key: ${env:AOAI_API_KEY}
api_type: azure
api_version: 2023-03-15-preview

3.Run pf connection create --file /connections/aoai.yaml
4. Run flow with set connection.

Expected behavior
WIth promptlow==1.9.0 everything works fine. Conection can be created and used where api_key is taken from environment variable.

Also everything works if set api_key explicitly:
pf connection create --file /connections/aoai.yaml --set api_key=$AOAI_API_KEY

Running Information(please complete the following information):

  • Promptflow Package Version: 1.10.1
  • Operating System: Ubuntu 20.04, MacOs Sonoma 14.4.1
  • Python Version using: 3.9.11
@AlexTeslenko AlexTeslenko added the bug Something isn't working label May 13, 2024
@brynn-code
Copy link
Contributor

@AlexTeslenko I just test 'pf flow test' and 'pf flow serve' with 1.9.0 and 1.10.1, we only commit this work for flow serve, and flow serve works well, while flow test doesn't work. Could you please elaborate more about your scenario, which command works fine before and broken afterwards?

@AlexTeslenko
Copy link
Author

@brynn-code thank you for checking this issue. I had this problem when I created docker image using promtflow and tried to run created image.

@brynn-code
Copy link
Contributor

brynn-code commented May 22, 2024

@AlexTeslenko Sounds like you are using the image by 'pf flow build'. When running 'pf flow build', the connection yaml will be re-extracted with an environment variable reference using default rule, so it could be different from your environment variable name in the original yaml. The name rule was expected as <connection_name>_, for example this is the api_key from the build result:
image
Could you please check the connection yaml under <your output path>/connections to see the env var name reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants