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 –target_name command line parameter, or pass it as an argument to the Generator constructor.
- class AzureOpenAIGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/stable/garak/_config.py'>)Source
Bases:
OpenAICompatibleWrapper for Azure Open AI. Expects AZURE_API_KEY, AZURE_ENDPOINT and AZURE_MODEL_NAME environment variables.
Uses the OpenAI-compatible API via direct HTTP request.
To get started with this generator:
Visit https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models and find the LLM you’d like to use.
Deploy a model and copy the model and deployment names.
On the Azure portal page for the Azure OpenAI you want to use click “Resource Management -> Keys and Endpoint” and copy the API Key and endpoint.
In your console, Set the
AZURE_API_KEY,AZURE_ENDPOINTandAZURE_MODEL_NAMEvariables.Run garak, setting
--target_typetoazureand--target_nameto the name of the deployment. - e.g.gpt-4o.
Configurable parameters:
DEFAULT_PARAMScontents:max_tokens=150temperature=0.7top_k=Nonecontext_len=Noneskip_seq_start=Noneskip_seq_end=Nonetop_p=1.0uri=Nonefrequency_penalty=0.0presence_penalty=0.0seed=Nonestop=['#', ';']suppressed_params=set()retry_json=Trueextra_params={}target_name=None
Default values are listed
See also Configuring garak for how to set these values.
Other attributes:
- 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'