Skip to content

Fully automatic censorship removal for language models

Support passing model name without "--model" argument prefix

Philipp Emanuel Weidmann7573a2eebd86
diff --git a/src/heretic/main.py b/src/heretic/main.py
index 2f7f2aa..517086f 100644
--- a/src/heretic/main.py
+++ b/src/heretic/main.py
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2025 Philipp Emanuel Weidmann <[email protected]>
+import sys
import time
from importlib.metadata import version
@@ -32,6 +33,16 @@ def main():
)
print()
+ if (
+ # An odd number of arguments have been passed (argv[0] is the program name),
+ # so that after accounting for "--param VALUE" pairs, there is one left over.
+ len(sys.argv) % 2 == 0
+ # The leftover argument is a parameter value rather than a flag (such as "--help").
+ and not sys.argv[-1].startswith("-")
+ ):
+ # Assume the last argument is the model.
+ sys.argv.insert(-1, "--model")
+
settings = Settings()
# Adapted from https://github.com/huggingface/accelerate/blob/main/src/accelerate/commands/env.py