Skip to content

Fully automatic censorship removal for language models

feat: turn boolean settings into CLI flags

Philipp Emanuel Weidmann24c3aeb4422d
diff --git a/src/heretic/config.py b/src/heretic/config.py
index b19b3fb..a69c059 100644
--- a/src/heretic/config.py
+++ b/src/heretic/config.py
@@ -213,6 +213,7 @@ class Settings(BaseSettings):
toml_file="config.toml",
env_prefix="HERETIC_",
cli_parse_args=True,
+ cli_implicit_flags=True,
cli_kebab_case=True,
)
diff --git a/src/heretic/main.py b/src/heretic/main.py
index fef36a7..34e8561 100644
--- a/src/heretic/main.py
+++ b/src/heretic/main.py
@@ -65,10 +65,11 @@ def run():
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").
+ # There is at least one argument (argv[0] is the program name).
+ len(sys.argv) > 1
+ # No model has been explicitly provided.
+ and "--model" not in sys.argv
+ # The last 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.