I'm building my first promptflow application and trying to create connection to the Azure AI Language resource so I can do things like Recognize Entities or extract Key Phrases. I have created a Language Resource in Azure and setup the project so that it will work in VSCode (including the install of the Azure Language package).
When adding a Language specific node to my flow, I then try and add a connection. This is where I'm having issues. First I try and create a Custom Connection and get the following template.
# Notices:
# - Don't replace the '<user-input>' placeholder in this file, the application will prompt you to enter a value when it runs.
# - Manually save the file will create the connection after basic validation.
# - The connection information will be stored in a local database with api_key encrypted for safety.
# - Prompt flow will ONLY use the connection information (incl. keys) when instructed by you, e.g. manage connections, use connections to run flow etc.
# - All the values should be string type, please use "123" instead of 123 or "True" instead of True.
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/CustomConnection.schema.json
name: "to_replace_with_connection_name"
type: custom
configs:
key1: "test1"
secrets:
# Don't replace the '<user-input>' placeholder. The application will prompt you to enter a value when it runs.
key2: "<user-input>"
The way I'm reading the instructions from Azure AI Language Connection Instructions I need to set the key1 value under config with the Azure Language Service Endpoint and the key2 value under Secrets should be Key value from my Azure Language Service instance. However when I enter the information in both, there is a failure stating that key 2 needs to remain as "". If I just enter the endpoint on key1 and keep key 2 as "" then I get an error in the terminal when pressing the "Create Connection" link in VSCode on the new_Custom_connection.yaml. The terminal error states the following.
from promptflow.azure.pf_client import PFClient as PFAzureClient File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow\azure_init.py", line 7, in from ._pf_client import PFClient File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow\azure_pf_client.py", line 8, in from azure.ai.ml import MLClient ModuleNotFoundError: No module named 'azure.ai'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users<user>.vscode\extensions\prompt-flow.prompt-flow-1.8.0\pfutil\pfutil.py", line 4, in
main()
File "c:\Users<user>.vscode\extensions\prompt-flow.prompt-flow-1.8.0\pfutil_pf_vsc_main.py", line 37, in main
operate_connection(args)
File "c:\Users<user>.vscode\extensions\prompt-flow.prompt-flow-1.8.0\pfutil_pf_vsc_connection.py", line 29, in operate_connection
upsert_connection(args)
File "c:\Users<user>.vscode\extensions\prompt-flow.prompt-flow-1.8.0\pfutil_pf_vsc_connection.py", line 58, in upsert_connection
connection = ConnectionOperations().create_or_update(connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow_sdk_telemetry\activity.py", line 175, in wrapper
return f(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow_sdk\operations_connection_operations.py", line 76, in create_or_update
orm_object = connection._to_orm_object()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow_sdk\entities_connection.py", line 885, in _to_orm_object
encrypted_secrets = self._validate_and_encrypt_secrets()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users<user>\miniconda3\envs\pf\Lib\site-packages\promptflow_sdk\entities_connection.py", line 156, in _validate_and_encrypt_secrets
raise ValueError(f"Connection {self.name!r} secrets {invalid_secrets} value invalid, please fill them.")
Any assistance helping me with what I'm sure is my own stupide mistake would be greatly appreciated!
It seems like you are having trouble creating a custom connection to the Azure AI Language resource in your Promptflow application. From the error message you provided, it appears that the issue is with the value of key2 in the secrets section of the connection template. The error message suggests that the value of key2 is invalid and needs to be filled in.
According to the instructions you mentioned, key2 should be set to the key value from your Azure Language Service instance. Make sure that you have entered the correct key value and that you have replaced the placeholder with the actual key value.