Fix LiteLLM API key source and auth header
- Load API key from durable file /root/.abiba-workspace/secrets/litellm-key.txt (works in cron) - Fix http_get to use Bearer token instead of Basic Auth for API endpoint check - All 6 LiteLLM checks now pass (was 5/6)
This commit is contained in:
@@ -29,7 +29,13 @@ LITELLM_PUBLIC = "https://litellm.sysloggh.net"
|
||||
LITELLM_BACKEND = "192.168.68.116"
|
||||
AUTH_HOST = "192.168.68.11"
|
||||
|
||||
SYNTHETIC_API_KEY = "sk-U_ydi3B-wfGU-_xESkoU1Q"
|
||||
# Load LiteLLM API key from file (durable, works in cron)
|
||||
LITELLM_KEY_FILE = "/root/.abiba-workspace/secrets/litellm-key.txt"
|
||||
try:
|
||||
with open(LITELLM_KEY_FILE) as f:
|
||||
SYNTHETIC_API_KEY = f.read().strip()
|
||||
except:
|
||||
SYNTHETIC_API_KEY = "sk-U_ydi3B-wfGU-_xESkoU1Q"
|
||||
|
||||
NOW = datetime.datetime.now()
|
||||
DATE_STR = NOW.strftime("%Y-%m-%d")
|
||||
@@ -68,7 +74,7 @@ def http_get(url, auth=None, timeout=10):
|
||||
cmd = f'curl -sfk --connect-timeout {timeout} -o /dev/null -w "%{{http_code}}" "{url}"'
|
||||
if auth:
|
||||
cmd = cmd.replace('"', '\\"')
|
||||
cmd = f'curl -sfk --connect-timeout {timeout} -u "{auth}" -o /dev/null -w "%{{http_code}}" "{url}"'
|
||||
cmd = f'curl -sfk --connect-timeout {timeout} -H "Authorization: Bearer {auth}" -o /dev/null -w "%{{http_code}}" "{url}"'
|
||||
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout+2)
|
||||
return r.stdout.strip() or "000"
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user