forked from phoenix/litellm-mirror
fix(proxy_cli.py): fix double counting json logs
This commit is contained in:
parent
c8a40eca05
commit
248ee488f0
2 changed files with 37 additions and 30 deletions
|
@ -67,6 +67,7 @@ model_list:
|
||||||
max_input_tokens: 80920
|
max_input_tokens: 80920
|
||||||
|
|
||||||
litellm_settings:
|
litellm_settings:
|
||||||
|
json_logs: true
|
||||||
default_team_settings:
|
default_team_settings:
|
||||||
- team_id: proj1
|
- team_id: proj1
|
||||||
success_callback: ["langfuse"]
|
success_callback: ["langfuse"]
|
||||||
|
@ -87,9 +88,9 @@ assistant_settings:
|
||||||
|
|
||||||
router_settings:
|
router_settings:
|
||||||
enable_pre_call_checks: true
|
enable_pre_call_checks: true
|
||||||
|
|
||||||
general_settings:
|
general_settings:
|
||||||
alerting: ["slack"]
|
alerting: ["slack"]
|
||||||
enable_jwt_auth: True
|
enable_jwt_auth: True
|
||||||
litellm_jwtauth:
|
litellm_jwtauth:
|
||||||
team_id_jwt_field: "client_id"
|
team_id_jwt_field: "client_id"
|
|
@ -1,11 +1,15 @@
|
||||||
import click
|
|
||||||
import subprocess, traceback, json
|
|
||||||
import os, sys
|
|
||||||
import random
|
|
||||||
from datetime import datetime
|
|
||||||
import importlib
|
import importlib
|
||||||
from dotenv import load_dotenv
|
import json
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import click
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
sys.path.append(os.getcwd())
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
@ -14,9 +18,8 @@ config_filename = "litellm.secrets"
|
||||||
litellm_mode = os.getenv("LITELLM_MODE", "DEV") # "PRODUCTION", "DEV"
|
litellm_mode = os.getenv("LITELLM_MODE", "DEV") # "PRODUCTION", "DEV"
|
||||||
if litellm_mode == "DEV":
|
if litellm_mode == "DEV":
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
from importlib import resources
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from importlib import resources
|
||||||
|
|
||||||
telemetry = None
|
telemetry = None
|
||||||
|
|
||||||
|
@ -230,28 +233,28 @@ def run_server(
|
||||||
args = locals()
|
args = locals()
|
||||||
if local:
|
if local:
|
||||||
from proxy_server import (
|
from proxy_server import (
|
||||||
app,
|
|
||||||
save_worker_config,
|
|
||||||
ProxyConfig,
|
|
||||||
KeyManagementSystem,
|
|
||||||
KeyManagementSettings,
|
KeyManagementSettings,
|
||||||
load_from_azure_key_vault,
|
KeyManagementSystem,
|
||||||
|
ProxyConfig,
|
||||||
|
app,
|
||||||
load_aws_kms,
|
load_aws_kms,
|
||||||
load_aws_secret_manager,
|
load_aws_secret_manager,
|
||||||
|
load_from_azure_key_vault,
|
||||||
load_google_kms,
|
load_google_kms,
|
||||||
|
save_worker_config,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
from .proxy_server import (
|
from .proxy_server import (
|
||||||
app,
|
|
||||||
save_worker_config,
|
|
||||||
ProxyConfig,
|
|
||||||
KeyManagementSystem,
|
|
||||||
KeyManagementSettings,
|
KeyManagementSettings,
|
||||||
load_from_azure_key_vault,
|
KeyManagementSystem,
|
||||||
|
ProxyConfig,
|
||||||
|
app,
|
||||||
load_aws_kms,
|
load_aws_kms,
|
||||||
load_aws_secret_manager,
|
load_aws_secret_manager,
|
||||||
|
load_from_azure_key_vault,
|
||||||
load_google_kms,
|
load_google_kms,
|
||||||
|
save_worker_config,
|
||||||
)
|
)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
if "litellm[proxy]" in str(e):
|
if "litellm[proxy]" in str(e):
|
||||||
|
@ -260,15 +263,15 @@ def run_server(
|
||||||
else:
|
else:
|
||||||
# this is just a local/relative import error, user git cloned litellm
|
# this is just a local/relative import error, user git cloned litellm
|
||||||
from proxy_server import (
|
from proxy_server import (
|
||||||
app,
|
|
||||||
save_worker_config,
|
|
||||||
ProxyConfig,
|
|
||||||
KeyManagementSystem,
|
|
||||||
KeyManagementSettings,
|
KeyManagementSettings,
|
||||||
load_from_azure_key_vault,
|
KeyManagementSystem,
|
||||||
|
ProxyConfig,
|
||||||
|
app,
|
||||||
load_aws_kms,
|
load_aws_kms,
|
||||||
load_aws_secret_manager,
|
load_aws_secret_manager,
|
||||||
|
load_from_azure_key_vault,
|
||||||
load_google_kms,
|
load_google_kms,
|
||||||
|
save_worker_config,
|
||||||
)
|
)
|
||||||
if version == True:
|
if version == True:
|
||||||
pkg_version = importlib.metadata.version("litellm")
|
pkg_version = importlib.metadata.version("litellm")
|
||||||
|
@ -277,7 +280,10 @@ def run_server(
|
||||||
if model and "ollama" in model and api_base is None:
|
if model and "ollama" in model and api_base is None:
|
||||||
run_ollama_serve()
|
run_ollama_serve()
|
||||||
if test_async is True:
|
if test_async is True:
|
||||||
import requests, concurrent, time # type: ignore
|
import concurrent
|
||||||
|
import time
|
||||||
|
|
||||||
|
import requests # type: ignore
|
||||||
|
|
||||||
api_base = f"http://{host}:{port}"
|
api_base = f"http://{host}:{port}"
|
||||||
|
|
||||||
|
@ -443,7 +449,9 @@ def run_server(
|
||||||
read from there and save it to os.env['DATABASE_URL']
|
read from there and save it to os.env['DATABASE_URL']
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
import yaml, asyncio # type: ignore
|
import asyncio
|
||||||
|
|
||||||
|
import yaml # type: ignore
|
||||||
except:
|
except:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"yaml needs to be imported. Run - `pip install 'litellm[proxy]'`"
|
"yaml needs to be imported. Run - `pip install 'litellm[proxy]'`"
|
||||||
|
@ -576,8 +584,8 @@ def run_server(
|
||||||
if port == 4000 and is_port_in_use(port):
|
if port == 4000 and is_port_in_use(port):
|
||||||
port = random.randint(1024, 49152)
|
port = random.randint(1024, 49152)
|
||||||
|
|
||||||
from litellm.proxy.proxy_server import app
|
|
||||||
import litellm
|
import litellm
|
||||||
|
from litellm.proxy.proxy_server import app
|
||||||
|
|
||||||
if run_gunicorn == False:
|
if run_gunicorn == False:
|
||||||
if ssl_certfile_path is not None and ssl_keyfile_path is not None:
|
if ssl_certfile_path is not None and ssl_keyfile_path is not None:
|
||||||
|
@ -593,8 +601,6 @@ def run_server(
|
||||||
) # run uvicorn
|
) # run uvicorn
|
||||||
else:
|
else:
|
||||||
if litellm.json_logs:
|
if litellm.json_logs:
|
||||||
from litellm.proxy._logging import logger
|
|
||||||
|
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app, host=host, port=port, log_config=None
|
app, host=host, port=port, log_config=None
|
||||||
) # run uvicorn w/ json
|
) # run uvicorn w/ json
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue