promptflow.connections module#

class promptflow.connections.AzureAIServicesConnection(endpoint: str, api_key: Optional[str] = None, auth_mode: str = 'key', **kwargs)#

Bases: _StrongTypeAADSupportedConnection

Azure AI Services connection.

Parameters:
  • api_key (str) – The api key.

  • endpoint (str) – The api endpoint.

  • auth_mode (str) – The auth mode, supported values see: ConnectionAuthMode.

  • name (str) – Connection name.

TYPE = 'AzureAIServices'#
property endpoint#

Return the connection endpoint.

class promptflow.connections.AzureContentSafetyConnection(api_key: str, endpoint: str, api_version: str = '2023-10-01', api_type: str = 'Content Safety', **kwargs)#

Bases: _StrongTypeConnection

Azure Content Safety connection.

Parameters:
  • api_key (str) – The api key.

  • endpoint (str) – The api endpoint.

  • api_version (str) – The api version, default see: AZURE_CONTENT_SAFETY.

  • api_type (str) – The api type, default β€œContent Safety”.

  • name (str) – Connection name.

TYPE = 'AzureContentSafety'#
property api_type#

Return the connection api type.

property api_version#

Return the connection api version.

property endpoint#

Return the connection endpoint.

class promptflow.connections.AzureOpenAIConnection(api_base: str, api_key: Optional[str] = None, api_type: str = 'azure', api_version: str = '2024-02-01', auth_mode: str = 'key', resource_id: Optional[str] = None, **kwargs)#

Bases: _StrongTypeAADSupportedConnection

Azure OpenAI connection.

Parameters:
  • api_key (str) – The api key.

  • api_base (str) – The api base.

  • api_type (str) – The api type, default β€œazure”.

  • api_version (str) – The api version, default see: AZURE_OPEN_AI

  • auth_mode (str) – The auth mode, supported values see: ConnectionAuthMode.

  • resource_id (str) – Optional, the arm resource id.

  • name (str) – Connection name.

TYPE = 'AzureOpenAI'#
property api_base#

Return the connection api base.

property api_type#

Return the connection api type.

property api_version#

Return the connection api version.

classmethod from_env(name=None)#

Build connection from environment variables.

Relevant environment variables:
  • AZURE_OPENAI_ENDPOINT: The api base.

  • AZURE_OPENAI_API_KEY: The api key.

  • OPENAI_API_VERSION: Optional.

The api version default to AZURE_OPEN_AI.

property resource_id#

Return the connection resource id.

class promptflow.connections.CognitiveSearchConnection(api_base: str, api_key: Optional[str] = None, api_version: str = '2023-11-01', auth_mode: str = 'key', **kwargs)#

Bases: _StrongTypeAADSupportedConnection

Cognitive Search connection.

Parameters:
  • api_key (str) – The api key.

  • api_base (str) – The api base.

  • api_version (str) – The api version, default β€œ2023-11-01”.

  • auth_mode (str) – The auth mode, supported values see: ConnectionAuthMode.

  • name (str) – Connection name.

TYPE = 'CognitiveSearch'#
property api_base#

Return the connection api base.

property api_version#

Return the connection api version.

class promptflow.connections.ConnectionProvider#

Bases: ABC

The connection provider interface to list/get connections in the current environment.

PROVIDER_CONFIG_KEY = 'PF_CONNECTION_PROVIDER'#
abstract get(name: str) _Connection#

Get connection by name.

classmethod get_instance(**kwargs) ConnectionProvider#

Get the connection provider instance in the current environment. It will return different implementations based on the current environment.

classmethod init_from_provider_config(provider_config: str, credential=None)#

Initialize the connection provider from a provider config.

Expected value: - local - azureml://subscriptions/<your-subscription>/resourceGroups/<your-resourcegroup>/ providers/Microsoft.MachineLearningServices/workspaces/<your-workspace>

abstract list(**kwargs) List[_Connection]#

List all connections without secrets.

class promptflow.connections.CustomConnection(secrets: Dict[str, str], configs: Optional[Dict[str, str]] = None, **kwargs)#

Bases: _Connection

Custom connection.

Parameters:
  • configs (Dict[str, str]) – The configs kv pairs.

  • secrets (Dict[str, str]) – The secrets kv pairs.

  • name (str) – Connection name

TYPE = 'Custom'#
is_secret(item)#

Check if item is a secret.

class promptflow.connections.CustomStrongTypeConnection(secrets: Dict[str, str], configs: Optional[Dict[str, str]] = None, **kwargs)#

Bases: _Connection

Custom strong type connection.

Note

This connection type should not be used directly. Below is an example of how to use CustomStrongTypeConnection:

class MyCustomConnection(CustomStrongTypeConnection):
    api_key: Secret
    api_base: str
Parameters:
  • configs (Dict[str, str]) – The configs kv pairs.

  • secrets (Dict[str, str]) – The secrets kv pairs.

  • name (str) – Connection name

class promptflow.connections.FormRecognizerConnection(api_key: str, endpoint: str, api_version: str = '2023-07-31', api_type: str = 'Form Recognizer', **kwargs)#

Bases: AzureContentSafetyConnection

Form Recognizer connection.

Parameters:
  • api_key (str) – The api key.

  • endpoint (str) – The api endpoint.

  • api_version (str) – The api version, default see: FORM_RECOGNIZER.

  • api_type (str) – The api type, default β€œForm Recognizer”.

  • name (str) – Connection name.

TYPE = 'FormRecognizer'#
class promptflow.connections.OpenAIConnection(api_key: str, organization: Optional[str] = None, base_url=None, **kwargs)#

Bases: _StrongTypeConnection

OpenAI connection.

Parameters:
  • api_key (str) – The api key.

  • organization (str) – Optional. The unique identifier for your organization which can be used in API requests.

  • base_url (str) – Optional. Specify when use customized api base, leave None to use OpenAI default api base.

  • name (str) – Connection name.

TYPE = 'OpenAI'#
property base_url#

Return the connection api base.

classmethod from_env(name=None)#

Build connection from environment variables.

Relevant environment variables: - OPENAI_API_KEY: The api key. - OPENAI_ORG_ID: Optional. The unique identifier for your organization which can be used in API requests. - OPENAI_BASE_URL: Optional. Specify when use customized api base, leave None to use OpenAI default api base.

property organization#

Return the connection organization.

class promptflow.connections.SerpConnection(api_key: str, **kwargs)#

Bases: _StrongTypeConnection

Serp connection.

Parameters:
  • api_key (str) – The api key.

  • name (str) – Connection name.

TYPE = 'Serp'#
class promptflow.connections.ServerlessConnection(api_key: str, api_base: str, **kwargs)#

Bases: _StrongTypeConnection

Serverless connection.

Parameters:
  • api_key (str) – The api key.

  • api_base (str) – The api base.

  • name (str) – Connection name.

TYPE = 'Serverless'#
property api_base#

Return the connection api base.