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] pf connection create complains that creating an AI connection can't be done from PromptFlow #3277

Open
pgr-lopes opened this issue May 15, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@pgr-lopes
Copy link

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
@pgr-lopes pgr-lopes added the bug Something isn't working label May 15, 2024
@brynn-code
Copy link
Contributor

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.

@brynn-code brynn-code self-assigned this May 15, 2024
@pgr-lopes
Copy link
Author

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.

@brynn-code
Copy link
Contributor

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.

@brynn-code
Copy link
Contributor

You could find the samples based on your requirements under the 'manage connections' doc page.
image

@VRAJP-07
Copy link

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)

@pgr-lopes
Copy link
Author

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

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

3 participants