aisbf 0.1.2__py3-none-any.whl → 0.2.0__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.
@@ -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.0
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,23 @@
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.2.0.data/data/share/aisbf/aisbf.sh,sha256=ntI4UPefBtU2jrTwMR3hddHEPG_pDyJyO0J3SD7e5PA,4574
7
+ aisbf-0.2.0.data/data/share/aisbf/autoselect.json,sha256=Anud0hTE1mehonmMmhOTPK2ANUxfruE2yMdLqiEkEUA,659
8
+ aisbf-0.2.0.data/data/share/aisbf/autoselect.md,sha256=F8PilhaYBs0qdpIxIkokrjtIOdhAx5Bi1tA0hyfnqps,4301
9
+ aisbf-0.2.0.data/data/share/aisbf/main.py,sha256=ikv0-3KVHbawExNy6X4juE_pjZKaggkv-qAcUrqCw_s,7809
10
+ aisbf-0.2.0.data/data/share/aisbf/providers.json,sha256=9L5GO6sQ2Z6zndGed0AckvYNV1DMr9r7tSdZ9fJxYlA,3934
11
+ aisbf-0.2.0.data/data/share/aisbf/requirements.txt,sha256=lp6cPakAO3lpTCwQ27THf-PNz_HIpzCELrtpdgo6-2o,133
12
+ aisbf-0.2.0.data/data/share/aisbf/rotations.json,sha256=SzbmMeTRR0vVTrYTMwxSPxjXLVr8zxjaI4HYRxjyExQ,2123
13
+ aisbf-0.2.0.data/data/share/aisbf/aisbf/__init__.py,sha256=xzoKjaB3ujvO5qPq9HMFP7s64f6Xqm5brq1JgQJ_6zw,2156
14
+ aisbf-0.2.0.data/data/share/aisbf/aisbf/config.py,sha256=-pJa69vw_d_VuGPYGgKNm0hhMEgbVYSg2ZdWNl8LubY,6349
15
+ aisbf-0.2.0.data/data/share/aisbf/aisbf/handlers.py,sha256=exBfP1oLHYxNvq_xqVbWCl1NPxZgn-tlZL7j7acE558,15828
16
+ aisbf-0.2.0.data/data/share/aisbf/aisbf/models.py,sha256=LT1NaQVAw0VWXL-j3hdfNlXCA9HeiET_O3GDj3t9XC4,1883
17
+ aisbf-0.2.0.data/data/share/aisbf/aisbf/providers.py,sha256=jQGKYqrb-1RB3s4XrKK7AbX-7W5Cl3HG7Yc_riMkcyA,11942
18
+ aisbf-0.2.0.dist-info/licenses/LICENSE.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
+ aisbf-0.2.0.dist-info/METADATA,sha256=jdi3vLj2TesFI1SprE2PuzEPczE9fLtm0Lt4zfLNwrA,4190
20
+ aisbf-0.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
21
+ aisbf-0.2.0.dist-info/entry_points.txt,sha256=zYLNG5rYg0OM6zVQuJnxt7yKd6bf2OM9jiHy1ydPudY,36
22
+ aisbf-0.2.0.dist-info/top_level.txt,sha256=D7THOopMCIUH203TRSRdc1e_MBOC4OLJTCrMGBcn4Gc,6
23
+ aisbf-0.2.0.dist-info/RECORD,,
@@ -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