test - team based logging on proxy

This commit is contained in:
Ishaan Jaff 2024-04-15 13:26:55 -07:00
parent 464d812fa9
commit ecc6aa060f
4 changed files with 30 additions and 4 deletions

View file

@ -4,6 +4,17 @@ model_list:
model: openai/fake
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
litellm_settings:
default_team_settings:
- team_id: team-1
success_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT1_PUBLIC # Project 1
langfuse_secret: os.environ/LANGFUSE_PROJECT1_SECRET # Project 1
- team_id: team-2
success_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT2_PUBLIC # Project 2
langfuse_secret: os.environ/LANGFUSE_PROJECT2_SECRET # Project 2
general_settings:
store_model_in_db: true
master_key: sk-1234

View file

@ -1896,7 +1896,12 @@ class ProxyConfig:
param_name = getattr(response, "param_name", None)
param_value = getattr(response, "param_value", None)
if param_name is not None and param_value is not None:
config[param_name] = param_value
# check if param_name is already in the config
if param_name in config:
if isinstance(config[param_name], dict):
config[param_name].update(param_value)
else:
config[param_name] = param_value
return config

View file

@ -66,6 +66,15 @@ litellm_settings:
request_timeout: 600
telemetry: False
context_window_fallbacks: [{"gpt-3.5-turbo": ["gpt-3.5-turbo-large"]}]
default_team_settings:
- team_id: team-1
success_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT1_PUBLIC # Project 1
langfuse_secret: os.environ/LANGFUSE_PROJECT1_SECRET # Project 1
- team_id: team-2
success_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT2_PUBLIC # Project 2
langfuse_secret: os.environ/LANGFUSE_PROJECT2_SECRET # Project 2
router_settings:
routing_strategy: usage-based-routing-v2

View file

@ -7,6 +7,7 @@ import aiohttp
import os
import dotenv
from dotenv import load_dotenv
import pytest
load_dotenv()
@ -103,9 +104,9 @@ async def test_team_logging():
generations = langfuse_client.get_generations(trace_id=_trace_id).data
print(generations)
assert len(generations) == 2
assert len(generations) == 1
except Exception as e:
print(e)
pytest.fail(f"Unexpected error: {str(e)}")
@pytest.mark.asyncio
@ -169,4 +170,4 @@ async def test_team_2logging():
assert len(generations_team_1) == 0
except Exception as e:
print(e)
pytest.fail("Team 2 logging failed: " + str(e))