aisbf 0.1.2__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aisbf/__init__.py CHANGED
@@ -43,7 +43,7 @@ from .providers import (
43
43
  )
44
44
  from .handlers import RequestHandler, RotationHandler, AutoselectHandler
45
45
 
46
- __version__ = "0.1.0"
46
+ __version__ = "0.2.0"
47
47
  __all__ = [
48
48
  # Config
49
49
  "config",
@@ -43,7 +43,7 @@ from .providers import (
43
43
  )
44
44
  from .handlers import RequestHandler, RotationHandler, AutoselectHandler
45
45
 
46
- __version__ = "0.1.0"
46
+ __version__ = "0.2.0"
47
47
  __all__ = [
48
48
  # Config
49
49
  "config",
@@ -0,0 +1,153 @@
1
+ #!/bin/bash
2
+ ########################################################
3
+ # Copyright (C) 2026 Stefy Lanza <stefy@nexlab.net>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ #
18
+ # Why did the programmer quit his job? Because he didn't get arrays!
19
+ ########################################################
20
+
21
+ # AISBF - AI Service Broker Framework || AI Should Be Free
22
+ # This script manages the AISBF server using the installed virtual environment
23
+
24
+ PIDFILE="/tmp/aisbf.pid"
25
+
26
+ # Determine the correct share directory at runtime
27
+ # Check for system installation first (/usr/share/aisbf)
28
+ if [ -d "/usr/share/aisbf" ]; then
29
+ SHARE_DIR="/usr/share/aisbf"
30
+ VENV_DIR="/usr/share/aisbf/venv"
31
+ # Running as root - use /var/log/aisbf
32
+ LOG_DIR="/var/log/aisbf"
33
+ else
34
+ # Fall back to user installation (~/.local/share/aisbf)
35
+ SHARE_DIR="$HOME/.local/share/aisbf"
36
+ VENV_DIR="$HOME/.local/share/aisbf/venv"
37
+ # Running as user - use ~/.local/var/log/aisbf
38
+ LOG_DIR="$HOME/.local/var/log/aisbf"
39
+ fi
40
+
41
+ # Create log directory if it doesn't exist
42
+ mkdir -p "$LOG_DIR"
43
+
44
+ # Function to create venv if it doesn't exist
45
+ ensure_venv() {
46
+ if [ ! -d "$VENV_DIR" ]; then
47
+ echo "Creating virtual environment at $VENV_DIR"
48
+ python3 -m venv "$VENV_DIR"
49
+
50
+ # Install requirements if requirements.txt exists
51
+ if [ -f "$SHARE_DIR/requirements.txt" ]; then
52
+ echo "Installing requirements from $SHARE_DIR/requirements.txt"
53
+ "$VENV_DIR/bin/pip" install -r "$SHARE_DIR/requirements.txt"
54
+ fi
55
+
56
+ # Install aisbf package from system site-packages into venv
57
+ # This allows the venv to find the aisbf module
58
+ echo "Installing aisbf package in venv"
59
+ "$VENV_DIR/bin/pip" install aisbf
60
+ fi
61
+ }
62
+
63
+ # Function to start the server
64
+ start_server() {
65
+ # Ensure venv exists
66
+ ensure_venv
67
+
68
+ # Activate the virtual environment
69
+ source $VENV_DIR/bin/activate
70
+
71
+ # Change to share directory where main.py is located
72
+ cd $SHARE_DIR
73
+
74
+ # Start the proxy server with logging
75
+ uvicorn main:app --host 0.0.0.0 --port 8000 2>&1 | tee -a "$LOG_DIR/aisbf_stdout.log"
76
+ }
77
+
78
+ # Function to start as daemon
79
+ start_daemon() {
80
+ # Check if already running
81
+ if [ -f "$PIDFILE" ]; then
82
+ PID=$(cat "$PIDFILE")
83
+ if ps -p "$PID" > /dev/null 2>&1; then
84
+ echo "AISBF is already running (PID: $PID)"
85
+ exit 1
86
+ else
87
+ # Stale PID file, remove it
88
+ rm -f "$PIDFILE"
89
+ fi
90
+ fi
91
+
92
+ # Ensure venv exists
93
+ ensure_venv
94
+
95
+ # Start in background with nohup and logging
96
+ nohup bash -c "source $VENV_DIR/bin/activate && cd $SHARE_DIR && uvicorn main:app --host 0.0.0.0 --port 8000" >> "$LOG_DIR/aisbf_stdout.log" 2>&1 &
97
+ PID=$!
98
+ echo $PID > "$PIDFILE"
99
+ echo "AISBF started in background (PID: $PID)"
100
+ echo "Logs are being written to: $LOG_DIR"
101
+ }
102
+
103
+ # Function to check status
104
+ check_status() {
105
+ if [ -f "$PIDFILE" ]; then
106
+ PID=$(cat "$PIDFILE")
107
+ if ps -p "$PID" > /dev/null 2>&1; then
108
+ echo "AISBF is running (PID: $PID)"
109
+ exit 0
110
+ else
111
+ echo "AISBF is not running (stale PID file)"
112
+ rm -f "$PIDFILE"
113
+ exit 1
114
+ fi
115
+ else
116
+ echo "AISBF is not running"
117
+ exit 1
118
+ fi
119
+ }
120
+
121
+ # Function to stop the daemon
122
+ stop_daemon() {
123
+ if [ -f "$PIDFILE" ]; then
124
+ PID=$(cat "$PIDFILE")
125
+ if ps -p "$PID" > /dev/null 2>&1; then
126
+ kill "$PID"
127
+ rm -f "$PIDFILE"
128
+ echo "AISBF stopped (PID: $PID)"
129
+ else
130
+ echo "AISBF is not running (stale PID file)"
131
+ rm -f "$PIDFILE"
132
+ fi
133
+ else
134
+ echo "AISBF is not running"
135
+ fi
136
+ }
137
+
138
+ # Main command handling
139
+ case "$1" in
140
+ daemon)
141
+ start_daemon
142
+ ;;
143
+ status)
144
+ check_status
145
+ ;;
146
+ stop)
147
+ stop_daemon
148
+ ;;
149
+ *)
150
+ # Default: start in foreground
151
+ start_server
152
+ ;;
153
+ esac
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aisbf
3
- Version: 0.1.2
3
+ Version: 0.2.2
4
4
  Summary: AISBF - AI Service Broker Framework || AI Should Be Free - A modular proxy server for managing multiple AI provider integrations
5
5
  Home-page: https://git.nexlab.net/nexlab/aisbf.git
6
6
  Author: AISBF Contributors
@@ -0,0 +1,24 @@
1
+ cli.py,sha256=SpjVC1iBdDhQXuhJcjVFkODu4BH-nj_1hNFD_d8wPbw,2503
2
+ aisbf/__init__.py,sha256=D3-tZRWCu31CltN_pjx8IikwPl0OGEJkvoASm8QjvcQ,2156
3
+ aisbf/config.py,sha256=-pJa69vw_d_VuGPYGgKNm0hhMEgbVYSg2ZdWNl8LubY,6349
4
+ aisbf/handlers.py,sha256=exBfP1oLHYxNvq_xqVbWCl1NPxZgn-tlZL7j7acE558,15828
5
+ aisbf/models.py,sha256=LT1NaQVAw0VWXL-j3hdfNlXCA9HeiET_O3GDj3t9XC4,1883
6
+ aisbf/providers.py,sha256=jQGKYqrb-1RB3s4XrKK7AbX-7W5Cl3HG7Yc_riMkcyA,11942
7
+ aisbf-0.2.2.data/data/share/aisbf/aisbf.sh,sha256=ntI4UPefBtU2jrTwMR3hddHEPG_pDyJyO0J3SD7e5PA,4574
8
+ aisbf-0.2.2.data/data/share/aisbf/autoselect.json,sha256=Anud0hTE1mehonmMmhOTPK2ANUxfruE2yMdLqiEkEUA,659
9
+ aisbf-0.2.2.data/data/share/aisbf/autoselect.md,sha256=F8PilhaYBs0qdpIxIkokrjtIOdhAx5Bi1tA0hyfnqps,4301
10
+ aisbf-0.2.2.data/data/share/aisbf/main.py,sha256=ikv0-3KVHbawExNy6X4juE_pjZKaggkv-qAcUrqCw_s,7809
11
+ aisbf-0.2.2.data/data/share/aisbf/providers.json,sha256=9L5GO6sQ2Z6zndGed0AckvYNV1DMr9r7tSdZ9fJxYlA,3934
12
+ aisbf-0.2.2.data/data/share/aisbf/requirements.txt,sha256=lp6cPakAO3lpTCwQ27THf-PNz_HIpzCELrtpdgo6-2o,133
13
+ aisbf-0.2.2.data/data/share/aisbf/rotations.json,sha256=SzbmMeTRR0vVTrYTMwxSPxjXLVr8zxjaI4HYRxjyExQ,2123
14
+ aisbf-0.2.2.data/data/share/aisbf/aisbf/__init__.py,sha256=D3-tZRWCu31CltN_pjx8IikwPl0OGEJkvoASm8QjvcQ,2156
15
+ aisbf-0.2.2.data/data/share/aisbf/aisbf/config.py,sha256=-pJa69vw_d_VuGPYGgKNm0hhMEgbVYSg2ZdWNl8LubY,6349
16
+ aisbf-0.2.2.data/data/share/aisbf/aisbf/handlers.py,sha256=exBfP1oLHYxNvq_xqVbWCl1NPxZgn-tlZL7j7acE558,15828
17
+ aisbf-0.2.2.data/data/share/aisbf/aisbf/models.py,sha256=LT1NaQVAw0VWXL-j3hdfNlXCA9HeiET_O3GDj3t9XC4,1883
18
+ aisbf-0.2.2.data/data/share/aisbf/aisbf/providers.py,sha256=jQGKYqrb-1RB3s4XrKK7AbX-7W5Cl3HG7Yc_riMkcyA,11942
19
+ aisbf-0.2.2.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
20
+ aisbf-0.2.2.dist-info/METADATA,sha256=gi0VlbVGDAR2oAwVMmJaOU-8xIksAY3vKMI2i6UGXbE,4190
21
+ aisbf-0.2.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
22
+ aisbf-0.2.2.dist-info/entry_points.txt,sha256=dV_E5f6UvgSe9AoyPTzGxBK8IYaIeLR8yTe7EwBZ3F8,35
23
+ aisbf-0.2.2.dist-info/top_level.txt,sha256=odXp1LYymu31EdVSmMGCg3ZYAI5HeB8tZkaXh9Pw3kE,10
24
+ aisbf-0.2.2.dist-info/RECORD,,
@@ -1,2 +1,2 @@
1
1
  [console_scripts]
2
- aisbf = main:main
2
+ aisbf = cli:main
cli.py ADDED
@@ -0,0 +1,67 @@
1
+ """
2
+ Copyright (C) 2026 Stefy Lanza <stefy@nexlab.net>
3
+
4
+ AISBF - AI Service Broker Framework || AI Should Be Free
5
+
6
+ Python CLI wrapper that calls the aisbf.sh shell script.
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+
21
+ Why did the programmer quit his job? Because he didn't get arrays!
22
+ """
23
+
24
+ import os
25
+ import sys
26
+ import subprocess
27
+ from pathlib import Path
28
+
29
+
30
+ def main():
31
+ """Main entry point for the aisbf CLI - calls the aisbf.sh shell script"""
32
+
33
+ # Determine the correct script path at runtime
34
+ # Check for system installation first (/usr/local/share/aisbf/aisbf.sh)
35
+ script_path = Path("/usr/local/share/aisbf/aisbf.sh")
36
+ if not script_path.exists():
37
+ # Fall back to user installation (~/.local/share/aisbf/aisbf.sh)
38
+ script_path = Path.home() / ".local" / "share" / "aisbf" / "aisbf.sh"
39
+
40
+ # Check if the script exists
41
+ if not script_path.exists():
42
+ print(f"Error: AISBF script not found at {script_path}", file=sys.stderr)
43
+ print("Please ensure AISBF is properly installed.", file=sys.stderr)
44
+ print(f"Expected locations:", file=sys.stderr)
45
+ print(f" - /usr/local/share/aisbf/aisbf.sh (system-wide)", file=sys.stderr)
46
+ print(f" - ~/.local/share/aisbf/aisbf.sh (user installation)", file=sys.stderr)
47
+ sys.exit(1)
48
+
49
+ # Execute the shell script with all arguments passed to this Python script
50
+ try:
51
+ # Use subprocess to run the shell script
52
+ result = subprocess.run(
53
+ [str(script_path)] + sys.argv[1:],
54
+ check=False
55
+ )
56
+ # Exit with the same exit code as the shell script
57
+ sys.exit(result.returncode)
58
+ except KeyboardInterrupt:
59
+ # Handle Ctrl-C gracefully
60
+ sys.exit(130) # Standard exit code for SIGINT (128 + 2)
61
+ except Exception as e:
62
+ print(f"Error executing AISBF script: {e}", file=sys.stderr)
63
+ sys.exit(1)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
@@ -1,22 +0,0 @@
1
- aisbf/__init__.py,sha256=xzoKjaB3ujvO5qPq9HMFP7s64f6Xqm5brq1JgQJ_6zw,2156
2
- aisbf/config.py,sha256=-pJa69vw_d_VuGPYGgKNm0hhMEgbVYSg2ZdWNl8LubY,6349
3
- aisbf/handlers.py,sha256=exBfP1oLHYxNvq_xqVbWCl1NPxZgn-tlZL7j7acE558,15828
4
- aisbf/models.py,sha256=LT1NaQVAw0VWXL-j3hdfNlXCA9HeiET_O3GDj3t9XC4,1883
5
- aisbf/providers.py,sha256=jQGKYqrb-1RB3s4XrKK7AbX-7W5Cl3HG7Yc_riMkcyA,11942
6
- aisbf-0.1.2.data/data/share/aisbf/autoselect.json,sha256=Anud0hTE1mehonmMmhOTPK2ANUxfruE2yMdLqiEkEUA,659
7
- aisbf-0.1.2.data/data/share/aisbf/autoselect.md,sha256=F8PilhaYBs0qdpIxIkokrjtIOdhAx5Bi1tA0hyfnqps,4301
8
- aisbf-0.1.2.data/data/share/aisbf/main.py,sha256=ikv0-3KVHbawExNy6X4juE_pjZKaggkv-qAcUrqCw_s,7809
9
- aisbf-0.1.2.data/data/share/aisbf/providers.json,sha256=9L5GO6sQ2Z6zndGed0AckvYNV1DMr9r7tSdZ9fJxYlA,3934
10
- aisbf-0.1.2.data/data/share/aisbf/requirements.txt,sha256=lp6cPakAO3lpTCwQ27THf-PNz_HIpzCELrtpdgo6-2o,133
11
- aisbf-0.1.2.data/data/share/aisbf/rotations.json,sha256=SzbmMeTRR0vVTrYTMwxSPxjXLVr8zxjaI4HYRxjyExQ,2123
12
- aisbf-0.1.2.data/data/share/aisbf/aisbf/__init__.py,sha256=xzoKjaB3ujvO5qPq9HMFP7s64f6Xqm5brq1JgQJ_6zw,2156
13
- aisbf-0.1.2.data/data/share/aisbf/aisbf/config.py,sha256=-pJa69vw_d_VuGPYGgKNm0hhMEgbVYSg2ZdWNl8LubY,6349
14
- aisbf-0.1.2.data/data/share/aisbf/aisbf/handlers.py,sha256=exBfP1oLHYxNvq_xqVbWCl1NPxZgn-tlZL7j7acE558,15828
15
- aisbf-0.1.2.data/data/share/aisbf/aisbf/models.py,sha256=LT1NaQVAw0VWXL-j3hdfNlXCA9HeiET_O3GDj3t9XC4,1883
16
- aisbf-0.1.2.data/data/share/aisbf/aisbf/providers.py,sha256=jQGKYqrb-1RB3s4XrKK7AbX-7W5Cl3HG7Yc_riMkcyA,11942
17
- aisbf-0.1.2.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
18
- aisbf-0.1.2.dist-info/METADATA,sha256=6sEQEA2ODxnpdp5ipSEcRobFzniwGyyLDDotDdbOOP8,4190
19
- aisbf-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
20
- aisbf-0.1.2.dist-info/entry_points.txt,sha256=zYLNG5rYg0OM6zVQuJnxt7yKd6bf2OM9jiHy1ydPudY,36
21
- aisbf-0.1.2.dist-info/top_level.txt,sha256=D7THOopMCIUH203TRSRdc1e_MBOC4OLJTCrMGBcn4Gc,6
22
- aisbf-0.1.2.dist-info/RECORD,,
File without changes