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.