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
|
||||
|
||||
litellm_settings:
|
||||
json_logs: true
|
||||
default_team_settings:
|
||||
- team_id: proj1
|
||||
success_callback: ["langfuse"]
|
||||
|
@ -87,9 +88,9 @@ assistant_settings:
|
|||
|
||||
router_settings:
|
||||
enable_pre_call_checks: true
|
||||
|
||||
|
||||
general_settings:
|
||||
alerting: ["slack"]
|
||||
enable_jwt_auth: True
|
||||
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
|
||||
from dotenv import load_dotenv
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
import urllib.parse as urlparse
|
||||
from datetime import datetime
|
||||
|
||||
import click
|
||||
from dotenv import load_dotenv
|
||||
|
||||
sys.path.append(os.getcwd())
|
||||
|
||||
|
@ -14,9 +18,8 @@ config_filename = "litellm.secrets"
|
|||
litellm_mode = os.getenv("LITELLM_MODE", "DEV") # "PRODUCTION", "DEV"
|
||||
if litellm_mode == "DEV":
|
||||
load_dotenv()
|
||||
from importlib import resources
|
||||
import shutil
|
||||
|
||||
from importlib import resources
|
||||
|
||||
telemetry = None
|
||||
|
||||
|
@ -230,28 +233,28 @@ def run_server(
|
|||
args = locals()
|
||||
if local:
|
||||
from proxy_server import (
|
||||
app,
|
||||
save_worker_config,
|
||||
ProxyConfig,
|
||||
KeyManagementSystem,
|
||||
KeyManagementSettings,
|
||||
load_from_azure_key_vault,
|
||||
KeyManagementSystem,
|
||||
ProxyConfig,
|
||||
app,
|
||||
load_aws_kms,
|
||||
load_aws_secret_manager,
|
||||
load_from_azure_key_vault,
|
||||
load_google_kms,
|
||||
save_worker_config,
|
||||
)
|
||||
else:
|
||||
try:
|
||||
from .proxy_server import (
|
||||
app,
|
||||
save_worker_config,
|
||||
ProxyConfig,
|
||||
KeyManagementSystem,
|
||||
KeyManagementSettings,
|
||||
load_from_azure_key_vault,
|
||||
KeyManagementSystem,
|
||||
ProxyConfig,
|
||||
app,
|
||||
load_aws_kms,
|
||||
load_aws_secret_manager,
|
||||
load_from_azure_key_vault,
|
||||
load_google_kms,
|
||||
save_worker_config,
|
||||
)
|
||||
except ImportError as e:
|
||||
if "litellm[proxy]" in str(e):
|
||||
|
@ -260,15 +263,15 @@ def run_server(
|
|||
else:
|
||||
# this is just a local/relative import error, user git cloned litellm
|
||||
from proxy_server import (
|
||||
app,
|
||||
save_worker_config,
|
||||
ProxyConfig,
|
||||
KeyManagementSystem,
|
||||
KeyManagementSettings,
|
||||
load_from_azure_key_vault,
|
||||
KeyManagementSystem,
|
||||
ProxyConfig,
|
||||
app,
|
||||
load_aws_kms,
|
||||
load_aws_secret_manager,
|
||||
load_from_azure_key_vault,
|
||||
load_google_kms,
|
||||
save_worker_config,
|
||||
)
|
||||
if version == True:
|
||||
pkg_version = importlib.metadata.version("litellm")
|
||||
|
@ -277,7 +280,10 @@ def run_server(
|
|||
if model and "ollama" in model and api_base is None:
|
||||
run_ollama_serve()
|
||||
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}"
|
||||
|
||||
|
@ -443,7 +449,9 @@ def run_server(
|
|||
read from there and save it to os.env['DATABASE_URL']
|
||||
"""
|
||||
try:
|
||||
import yaml, asyncio # type: ignore
|
||||
import asyncio
|
||||
|
||||
import yaml # type: ignore
|
||||
except:
|
||||
raise ImportError(
|
||||
"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):
|
||||
port = random.randint(1024, 49152)
|
||||
|
||||
from litellm.proxy.proxy_server import app
|
||||
import litellm
|
||||
from litellm.proxy.proxy_server import app
|
||||
|
||||
if run_gunicorn == False:
|
||||
if ssl_certfile_path is not None and ssl_keyfile_path is not None:
|
||||
|
@ -593,8 +601,6 @@ def run_server(
|
|||
) # run uvicorn
|
||||
else:
|
||||
if litellm.json_logs:
|
||||
from litellm.proxy._logging import logger
|
||||
|
||||
uvicorn.run(
|
||||
app, host=host, port=port, log_config=None
|
||||
) # run uvicorn w/ json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue