Spaces:
Paused
Paused
Automated deployment update from ML build
Browse files
services/llm_proxy_service.py
CHANGED
|
@@ -8,16 +8,21 @@ CONFIG_PATH='/home/user/litellm.yaml'
|
|
| 8 |
PORT=8080
|
| 9 |
PREFIX='[llm-proxy]'
|
| 10 |
def _build_config():
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
if not B:return''
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
D=C.split(':',2)
|
| 16 |
-
if len(D)!=3:logger.warning(f"{PREFIX} Skipping malformed LLM_KEYS entry: {C!r}");continue
|
| 17 |
-
F,E,G=D;A.append(f' - model_name: {E}\n litellm_params:\n model: {F}/{E}\n api_key: "{G}"\n')
|
| 18 |
-
if not A:return''
|
| 19 |
-
H=''.join(A);return f"""model_list:
|
| 20 |
-
{H}
|
| 21 |
router_settings:
|
| 22 |
routing_strategy: least-busy
|
| 23 |
num_retries: 3
|
|
|
|
| 8 |
PORT=8080
|
| 9 |
PREFIX='[llm-proxy]'
|
| 10 |
def _build_config():
|
| 11 |
+
D='*';E=deobfuscate_secret(os.environ.pop('LLM_KEYS','').strip())
|
| 12 |
+
if not E:return''
|
| 13 |
+
B=[]
|
| 14 |
+
for F in(A.strip()for A in E.split(',')if A.strip()):
|
| 15 |
+
G=F.split(':',2)
|
| 16 |
+
if len(G)!=3:logger.warning(f"{PREFIX} Skipping malformed LLM_KEYS entry: {F!r}");continue
|
| 17 |
+
C,A,J=G
|
| 18 |
+
if A.startswith(f"{C}/")or A==D:H=A if A!=D else f"{C}/*"
|
| 19 |
+
else:H=f"{C}/{A}"
|
| 20 |
+
I=f' - model_name: "{A}"\n litellm_params:\n model: {H}\n api_key: "{J}"\n'
|
| 21 |
+
if D in A:I+=' litellm_settings:\n check_provider_endpoint: true\n'
|
| 22 |
+
B.append(I)
|
| 23 |
if not B:return''
|
| 24 |
+
K=''.join(B);return f"""model_list:
|
| 25 |
+
{K}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
router_settings:
|
| 27 |
routing_strategy: least-busy
|
| 28 |
num_retries: 3
|