wuenlp_tools.configure_proxy

CLI script for configuring LightLLM proxy settings.

Usage: python -m wuenlp_tools.configure_proxy [command]

Commands: setup - Interactive proxy configuration (default) status - Show current proxy status disable - Disable proxy help - Show this help message

 1#!/usr/bin/env python3
 2"""
 3CLI script for configuring LightLLM proxy settings.
 4
 5Usage:
 6    python -m wuenlp_tools.configure_proxy [command]
 7
 8Commands:
 9    setup    - Interactive proxy configuration (default)
10    status   - Show current proxy status
11    disable  - Disable proxy
12    help     - Show this help message
13"""
14
15import sys
16from typing import Optional
17
18
19def main():
20    """Main CLI entry point."""
21    command = sys.argv[1] if len(sys.argv) > 1 else "setup"
22
23    if command in ["help", "-h", "--help"]:
24        print(__doc__)
25        return 0
26
27    try:
28        from wuenlp_tools.config import (
29            configure_lightllm_proxy,
30            read_llm_config,
31            show_lightllm_status,
32            write_llm_config,
33        )
34    except ImportError as e:
35        print(f"❌ Error importing wuenlp_tools: {e}")
36        print(
37            "Make sure you're in the correct environment and wuenlp-tools is installed."
38        )
39        return 1
40
41    if command == "setup":
42        try:
43            configure_lightllm_proxy()
44        except KeyboardInterrupt:
45            print("\n❌ Configuration cancelled by user")
46            return 1
47        except Exception as e:
48            print(f"❌ Error during configuration: {e}")
49            return 1
50
51    elif command == "status":
52        try:
53            show_lightllm_status()
54        except Exception as e:
55            print(f"❌ Error showing status: {e}")
56            return 1
57
58    elif command == "disable":
59        try:
60            config = read_llm_config()
61            config["lightllm_proxy"] = {"enabled": False}
62            write_llm_config(config)
63            print("✅ LightLLM proxy disabled")
64        except Exception as e:
65            print(f"❌ Error disabling proxy: {e}")
66            return 1
67
68    else:
69        print(f"❌ Unknown command: {command}")
70        print("Available commands: setup, status, disable, help")
71        return 1
72
73    return 0
74
75
76if __name__ == "__main__":
77    sys.exit(main())
def main():
20def main():
21    """Main CLI entry point."""
22    command = sys.argv[1] if len(sys.argv) > 1 else "setup"
23
24    if command in ["help", "-h", "--help"]:
25        print(__doc__)
26        return 0
27
28    try:
29        from wuenlp_tools.config import (
30            configure_lightllm_proxy,
31            read_llm_config,
32            show_lightllm_status,
33            write_llm_config,
34        )
35    except ImportError as e:
36        print(f"❌ Error importing wuenlp_tools: {e}")
37        print(
38            "Make sure you're in the correct environment and wuenlp-tools is installed."
39        )
40        return 1
41
42    if command == "setup":
43        try:
44            configure_lightllm_proxy()
45        except KeyboardInterrupt:
46            print("\n❌ Configuration cancelled by user")
47            return 1
48        except Exception as e:
49            print(f"❌ Error during configuration: {e}")
50            return 1
51
52    elif command == "status":
53        try:
54            show_lightllm_status()
55        except Exception as e:
56            print(f"❌ Error showing status: {e}")
57            return 1
58
59    elif command == "disable":
60        try:
61            config = read_llm_config()
62            config["lightllm_proxy"] = {"enabled": False}
63            write_llm_config(config)
64            print("✅ LightLLM proxy disabled")
65        except Exception as e:
66            print(f"❌ Error disabling proxy: {e}")
67            return 1
68
69    else:
70        print(f"❌ Unknown command: {command}")
71        print("Available commands: setup, status, disable, help")
72        return 1
73
74    return 0

Main CLI entry point.