garak.generators.litellm
LiteLLM model support
Support for LiteLLM, which allows calling LLM APIs using the OpenAI format.
Depending on the model name provider, LiteLLM automatically
reads API keys from the respective environment variables
such as OPENAI_API_KEY for OpenAI models.
Create a file, such as ollama_base.json, with content like the following
to connect LiteLLM with the Ollama OAI API:
{
"litellm": {
"LiteLLMGenerator" : {
"api_base" : "http://localhost:11434/v1",
"provider" : "openai"
}
}
}
When invoking garak, specify the path to the generator option file:
python -m garak --target_type litellm --target_name "phi" --generator_option_file ollama_base.json -p dan
- class LiteLLMGenerator(name: str = '', generations: int = 10, config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/stable/garak/_config.py'>)Source
Bases:
GeneratorGenerator wrapper using LiteLLM to allow access to different providers using the OpenAI API format.
Configurable parameters:
DEFAULT_PARAMScontents:max_tokens=150temperature=0.7top_k=Nonecontext_len=Noneskip_seq_start=Noneskip_seq_end=Nonetop_p=1.0frequency_penalty=0.0presence_penalty=0.0stop=['#', ';']verbose=Falsesuppressed_params=set()
Default values are listed
See also Configuring garak for how to set these values.
Other attributes:
- extra_dependency_names = ['litellm']
- generator_family_name = 'LiteLLM'
- supports_multiple_generations = True