fix langfuse tests in_memory_langfuse_clients

This commit is contained in:
Ishaan Jaff 2024-06-22 13:58:09 -07:00
parent ebbe97910c
commit cb828a464a

View file

@ -20,8 +20,6 @@ import time
import pytest import pytest
in_memory_langfuse_client: dict[str, Any] = {}
@pytest.fixture @pytest.fixture
def langfuse_client(): def langfuse_client():
@ -31,15 +29,15 @@ def langfuse_client():
f"{os.environ['LANGFUSE_PUBLIC_KEY']}-{os.environ['LANGFUSE_SECRET_KEY']}" f"{os.environ['LANGFUSE_PUBLIC_KEY']}-{os.environ['LANGFUSE_SECRET_KEY']}"
) )
# use a in memory langfuse client for testing, RAM util on ci/cd gets too high when we init many langfuse clients # use a in memory langfuse client for testing, RAM util on ci/cd gets too high when we init many langfuse clients
if _langfuse_cache_key in in_memory_langfuse_clients: if _langfuse_cache_key in litellm.in_memory_llm_clients_cache:
langfuse_client = in_memory_langfuse_clients[_langfuse_cache_key] langfuse_client = litellm.in_memory_llm_clients_cache[_langfuse_cache_key]
else: else:
langfuse_client = langfuse.Langfuse( langfuse_client = langfuse.Langfuse(
public_key=os.environ["LANGFUSE_PUBLIC_KEY"], public_key=os.environ["LANGFUSE_PUBLIC_KEY"],
secret_key=os.environ["LANGFUSE_SECRET_KEY"], secret_key=os.environ["LANGFUSE_SECRET_KEY"],
host=None, host=None,
) )
in_memory_langfuse_clients[_langfuse_cache_key] = langfuse_client litellm.in_memory_llm_clients_cache[_langfuse_cache_key] = langfuse_client
print("NEW LANGFUSE CLIENT") print("NEW LANGFUSE CLIENT")