From 872cd2d8a00d002483d25df888c34dc7c83a96e7 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 3 Jun 2024 12:57:50 -0700 Subject: [PATCH] fix(langfuse.py): log litellm response cost as part of langfuse metadata --- litellm/__init__.py | 2 +- litellm/integrations/langfuse.py | 2 ++ litellm/proxy/_super_secret_config.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index af95fd5a38..cfc96ede82 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -215,7 +215,6 @@ add_function_to_prompt: bool = ( ) client_session: Optional[httpx.Client] = None aclient_session: Optional[httpx.AsyncClient] = None -module_level_aclient = AsyncHTTPHandler() model_fallbacks: Optional[List] = None # Deprecated for 'litellm.fallbacks' model_cost_map_url: str = ( "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json" @@ -232,6 +231,7 @@ max_user_budget: Optional[float] = None max_end_user_budget: Optional[float] = None #### RELIABILITY #### request_timeout: float = 6000 +module_level_aclient = AsyncHTTPHandler(timeout=request_timeout) num_retries: Optional[int] = None # per model endpoint default_fallbacks: Optional[List] = None fallbacks: Optional[List] = None diff --git a/litellm/integrations/langfuse.py b/litellm/integrations/langfuse.py index 12b20f3d31..4d580f6666 100644 --- a/litellm/integrations/langfuse.py +++ b/litellm/integrations/langfuse.py @@ -396,6 +396,8 @@ class LangFuseLogger: cost = kwargs.get("response_cost", None) print_verbose(f"trace: {cost}") + clean_metadata["litellm_response_cost"] = cost + if ( litellm._langfuse_default_tags is not None and isinstance(litellm._langfuse_default_tags, list) diff --git a/litellm/proxy/_super_secret_config.yaml b/litellm/proxy/_super_secret_config.yaml index 7f7bfb4d8c..6e458350cb 100644 --- a/litellm/proxy/_super_secret_config.yaml +++ b/litellm/proxy/_super_secret_config.yaml @@ -29,6 +29,12 @@ model_list: - model_name: tts litellm_params: model: openai/tts-1 +- model_name: gpt-4-turbo-preview + litellm_params: + api_base: https://openai-france-1234.openai.azure.com + api_key: os.environ/AZURE_FRANCE_API_KEY + model: azure/gpt-turbo + router_settings: enable_pre_call_checks: true