Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add generators.function docs & examples #437

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading