garak.generators.azure
Azure OpenAI generator
Supports chat + chatcompletion models. Put your API key in the AZURE_API_KEY environment variable, the azure openai endpoint in the AZURE_ENDPOINT environment variable and the azure openai model name in AZURE_MODEL_NAME environment variable.
Put the deployment name in either the –model_name command line parameter, or pass it as an argument to the Generator constructor.
- class garak.generators.azure.AzureOpenAIGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/docs/source/../../garak/_config.py'>)
Bases:
OpenAICompatible
Wrapper for Azure Open AI. Expects AZURE_API_KEY, AZURE_ENDPOINT and AZURE_MODEL_NAME environment variables.
Uses the [OpenAI-compatible API](https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation) via direct HTTP request.
To get started with this generator: #. Visit [https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models) and find the LLM you’d like to use. #. [Deploy a model](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model) and copy paste the model and deployment names. #. On the Azure portal page for the Azure OpenAI you want to use click on “Resource Management -> Keys and Endpoint” and copy paste the API Key and endpoint. #. In your console, Set the
AZURE_API_KEY
,AZURE_ENDPOINT
andAZURE_MODEL_NAME
variables. #. Run garak, setting--model_type
toazure
and--model_name
to the name of the deployment. - e.g.gpt-4o
.- DEFAULT_PARAMS = {'context_len': None, 'extra_params': {}, 'frequency_penalty': 0.0, 'max_tokens': 150, 'model_name': None, 'presence_penalty': 0.0, 'retry_json': True, 'seed': None, 'skip_seq_end': None, 'skip_seq_start': None, 'stop': ['#', ';'], 'suppressed_params': {}, 'temperature': 0.7, 'top_k': None, 'top_p': 1.0, 'uri': None}
- ENDPOINT_ENV_VAR = 'AZURE_ENDPOINT'
- ENV_VAR = 'AZURE_API_KEY'
- MODEL_NAME_ENV_VAR = 'AZURE_MODEL_NAME'
- active = True
- api_version = '2024-06-01'
- generator_family_name = 'Azure'