Spaces:
Running
Running
| """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() | |