Spaces:
Running
Running
File size: 2,186 Bytes
2129c29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | """NLProxy CLI entrypoint.
This module implements the top-level command dispatcher for
"python -m nlproxy" and routes subcommands to the CLI package.
Author: IntelliDeep Labs Team
License: BSL 1.1
"""
import sys
def main() -> None:
if len(sys.argv) < 2:
print("Usage: python -m nlproxy <command> [options]")
print("\nAvailable commands:")
print(" download_models Download and extract required ONNX models")
print(" compress Compress prompts with semantic analysis & safety")
print(" runserver Start the FastAPI server")
print(" tests Run the SDK test suite")
print(" help Show the NLProxy CLI reference")
sys.exit(1)
command = sys.argv[1]
remaining_args = sys.argv[2:]
try:
if command == "download_models":
from nlproxy.cli.download_models import main as download_main
sys.exit(download_main(remaining_args) if callable(download_main) else 0)
elif command == "compress":
from nlproxy.cli.compress import main as compress_main
sys.exit(compress_main(remaining_args) if callable(compress_main) else 0)
elif command == "runserver":
from nlproxy.cli.runserver import main as runserver_main
sys.exit(runserver_main(remaining_args) if callable(runserver_main) else 0)
elif command in ("tests", "test"):
from nlproxy.cli.tests import main as tests_main
sys.exit(tests_main(remaining_args))
elif command == "help":
from nlproxy.cli.help import print_help
print_help()
sys.exit(0)
else:
print(f"Error: Unknown command '{command}'")
print("Use 'python -m nlproxy help' to see available commands.")
sys.exit(1)
except ImportError as e:
print(f"Error: Module not found. Ensure 'nlproxy' is installed or in PYTHONPATH.\n{e}")
sys.exit(1)
except SystemExit as e:
sys.exit(e.code)
except Exception as e:
print(f"Unexpected error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
|