pyrit.prompt_target.OpenAITTSTarget#

class OpenAITTSTarget(voice: Literal['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] = 'alloy', response_format: Literal['flac', 'mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'ogg', 'wav', 'webm'] = 'mp3', model: Literal['tts-1', 'tts-1-hd'] = 'tts-1', language: str = 'en', api_version: str = '2024-03-01-preview', *args, **kwargs)[source]#

Bases: OpenAITarget

__init__(voice: Literal['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'] = 'alloy', response_format: Literal['flac', 'mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'ogg', 'wav', 'webm'] = 'mp3', model: Literal['tts-1', 'tts-1-hd'] = 'tts-1', language: str = 'en', api_version: str = '2024-03-01-preview', *args, **kwargs)[source]#

Abstract class that initializes an Azure or non-Azure OpenAI chat target.

Read more about the various models here: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models.

Parameters:
  • deployment_name (str, Optional) – The name of the deployment. Defaults to the AZURE_OPENAI_CHAT_DEPLOYMENT environment variable .

  • endpoint (str, Optional) – The endpoint URL for the Azure OpenAI service. Defaults to the AZURE_OPENAI_CHAT_ENDPOINT environment variable.

  • api_key (str, Optional) – The API key for accessing the Azure OpenAI service. Defaults to the AZURE_OPENAI_CHAT_KEY environment variable.

  • headers (str, Optional) – Headers of the endpoint (JSON).

  • is_azure_target (bool, Optional) – Whether the target is an Azure target.

  • use_aad_auth (bool, Optional) – When set to True, user authentication is used instead of API Key. DefaultAzureCredential is taken for https://cognitiveservices.azure.com/.default . Please run az login locally to leverage user AuthN.

  • api_version (str, Optional) – The version of the Azure OpenAI API. Defaults to “2024-06-01”.

  • max_requests_per_minute (int, Optional) – Number of requests the target can handle per minute before hitting a rate limit. The number of requests sent to the target will be capped at the value provided.

Methods

__init__([voice, response_format, model, ...])

Abstract class that initializes an Azure or non-Azure OpenAI chat target.

dispose_db_engine()

Dispose DuckDB database engine to release database connections and resources.

get_identifier()

send_chat_prompt_async(*, prompt, ...[, ...])

Sends a text prompt to the target without having to build the prompt request.

send_prompt_async(**kwargs)

Sends a normalized prompt async to the prompt target.

set_system_prompt(*, system_prompt, ...[, ...])

Sets the system prompt for the prompt target.

Attributes

ADDITIONAL_REQUEST_HEADERS

deployment_environment_variable

endpoint_uri_environment_variable

api_key_environment_variable

supported_converters

async send_prompt_async(**kwargs)#

Sends a normalized prompt async to the prompt target.