[BUG] pf connection create complains that creating an AI connection can't be done from PromptFlow
Describe the bug I'm trying to setup the following standard flow using the commands mentioned in the README.md file: https://github.com/microsoft/promptflow/tree/main/examples/flows/standard/web-classification
After doing the PF connection create using the exact configuration found in that readme file, I am getting the following error:
promptflow\_sdk\operations\_local_azure_connection_operations.py", line 154, in create_or_update raise NotImplementedError( NotImplementedError: Create or update Azure AI connection is not supported in promptflow, please manage it in Azure AI/machine learning studio, az ml cli or AzureML SDK
The docs do mention that the connection can be created using pf connection create, so I'm not sure why this is happening.
How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug: 1.Git clone the prompt flow repo, open a CMD line, install prompt flow and run the requirements file, try to create the connection
Expected behavior I would expect the connection to be created and it would be used by the prompt flow activities then.
Running Information(please complete the following information):
- Promptflow Package Version: { "promptflow": "1.9.0", "promptflow-core": "1.10.1", "promptflow-devkit": "1.10.1", "promptflow-tracing": "1.10.1" }
- Operating System: Win 11
- Python Version using
python --version: 3.11.7
Hi, for the create operation, promptflow now only supports create connection locally., but user is able to use both local connections and Azure AI connections. To create/use local connections, please set the connection provider to local, then refer to manage connections. To use Azure AI connections locally, refer to this guide.
Thanks Brynn. Do you have an actual example of this I can follow? I'm struggling to understand it, what does a "local connection" mean? I have an Azure OpenAI endpoint, the connection can never be local unless I'm misunderstanding something.
The 'local connection' I said means those connections meta we stored locally in the sqlite, while the Azure AI connection means those connection created in your AI project, and the connection meta stored in the project itself rather than local sqlite.
You could find the samples based on your requirements under the 'manage connections' doc page.
This is for establishing connection with Azure OpenAI in local. You can execute this code by giving all the necessary details for the connection. Try this, hope it helps.
from promptflow import PFClient
from promptflow.connections import AzureOpenAIConnection
pf_client = PFClient()
try:
con_name = "<connection-name>"
# Access the connections property to get the ConnectionOperations instance
connection_ops = pf_client.connections
# Attempt to get the connection by name
conn = connection_ops.get(name=con_name)
print("Connection already exists:", conn)
except Exception as e:
print("Connection does not exist. Creating a new one...")
connection = AzureOpenAIConnection(
name=con_name,
api_key="<api-key>",
api_base="<api-base>",
api_type="azure",
api_version="<api-version>"
)
# Create or update the connection
conn = connection_ops.create_or_update(connection)
print("Connection created successfully:", conn)
Thanks, I understand how it works via Python, I just wasn't getting how I was meant to specify that via cli. All examples from the connections never actually do anything to make it local or non local.
For anyone facing the same issue and trying to use the cli commands, all you have to do is literally this before running the pf connection create:
pf config set connection.provider=local
I would suggest updating this doc to reference the set connection option or direct the user to the pf config page so they can check it: https://microsoft.github.io/promptflow/how-to-guides/manage-connections.html
Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you!