Skip to content

Commit

Permalink
add generators.function docs & examples (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz authored Jan 26, 2024
1 parent b6705bf commit c6126d8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions garak/generators/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
Call a given function to use as a generator; specify this as either the
model name on the command line, or as the parameter to the constructor.
This generator is designed to be used programmatically, rather than
invoked from the CLI. An example usage might be:
```
import mymodule
import garak.generators.function
g = garak.generators.function.Single(name="mymodule#myfunction")
```
The target function is expected to take a string, and return a string.
Other arguments passed by garak are forwarded to the target function.
Note that one can import the intended target module into scope and then
invoke a garak run via garak's cli module, using something like:
```
import garak
import garak.cli
import mymodule
garak.cli.run("--model_type function --model_name mymodule#function_name --probes encoding.InjectBase32".split())
```
"""


Expand Down

0 comments on commit c6126d8

Please sign in to comment.