promptflow
promptflow copied to clipboard
[BUG] Unable to make azure openai connection
Describe the bug I've installed keyring, keyring.alt, and dbus-python in my conda environment in WSL and I am still getting Exception("Encryption key not found in keyring.").
This is when I'm running this command
> pf connection create -f openai_connection.yaml --set api_key=<api_key>
How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug:
- I cloned from this repository
https://github.com/microsoft/promptflow.git
- Installed requirements, and keyrings.alt
- used my openai_connection.yaml file from a copy of the file in promptflow/examples/connections/azure_openai.yml folder and filled it in
- ran
pf connection create -f
Expected behavior Expected behavior is that it adds this to the promptflow connections
Running Information(please complete the following information):
- Promptflow Package: 1.9.0
- Operating System: WSL
- Python Version: 3.11.8
Additional context traceback:
Traceback (most recent call last):
File "/home/iyobed/miniconda3/envs/promptflow/bin/pf", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/pf.py", line 14, in main
_main()
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/entry.py", line 153, in main
entry(command_args)
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/entry.py", line 134, in entry
cli_exception_and_telemetry_handler(run_command, activity_name)(args)
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_utils.py", line 384, in wrapper
raise e
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_utils.py", line 372, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/entry.py", line 85, in run_command
raise ex
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/entry.py", line 61, in run_command
dispatch_connection_commands(args)
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/_connection.py", line 256, in dispatch_connection_commands
create_connection(args.file, args.params_override, args.name)
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_cli/_pf/_connection.py", line 200, in create_connection
connection_ops.get(connection.name, raise_error=False)
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/_telemetry/activity.py", line 265, in wrapper
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/operations/_connection_operations.py", line 55, in get
return self._get(name, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/operations/_connection_operations.py", line 65, in _get
return _Connection._from_orm_object(orm_connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/entities/_connection.py", line 157, in _from_orm_object
obj = type_cls._from_orm_object_with_secrets(orm_object)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/entities/_connection.py", line 231, in _from_orm_object_with_secrets
obj.secrets = {k: decrypt_secret_value(obj.name, v) for k, v in obj.secrets.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/entities/_connection.py", line 231, in <dictcomp>
obj.secrets = {k: decrypt_secret_value(obj.name, v) for k, v in obj.secrets.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/iyobed/miniconda3/envs/promptflow/lib/python3.11/site-packages/promptflow/_sdk/_utils.py", line 162, in decrypt_secret_value
raise Exception("Encryption key not found in keyring.")
Exception: Encryption key not found in keyring.
Hi @IyobedZekarias , promptflow will create an encryption key to keyring when first use, the error raised seems because your local sqlite db has existing connections but encryption key not found in keyring, could you please try to delete the local db file (at ~/.promptflow/pf.sqlite) and have a next try?
ok this ended up working but it creates a new pf.sqlite file whenever I create a new connection and I have to delete again
The pf.sqlite is required to store connections, you don't need to care about it once it works. The db needs to be deleted before is because seems there are already connections inside it, but the required encryption key used to decrypt connection does not exist. Once the db got reset, encryption key will be re-created, and all things should go well. @IyobedZekarias