Skip to content

Stevefarthing/fix langfuse upgrade #10759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
pip install langchain
pip install lunary==0.2.5
pip install "azure-identity==1.16.1"
pip install "langfuse==2.45.0"
pip install "langfuse==2.60.4"
pip install "logfire==0.29.0"
pip install numpydoc
pip install traceloop-sdk==0.21.1
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
pip install langchain
pip install lunary==0.2.5
pip install "azure-identity==1.16.1"
pip install "langfuse==2.45.0"
pip install "langfuse==2.60.4"
pip install "logfire==0.29.0"
pip install numpydoc
pip install traceloop-sdk==0.21.1
Expand Down Expand Up @@ -315,7 +315,7 @@ jobs:
pip install langchain
pip install lunary==0.2.5
pip install "azure-identity==1.16.1"
pip install "langfuse==2.45.0"
pip install "langfuse==2.60.4"
pip install "logfire==0.29.0"
pip install numpydoc
pip install traceloop-sdk==0.21.1
Expand Down Expand Up @@ -571,7 +571,7 @@ jobs:
pip install langchain
pip install lunary==0.2.5
pip install "azure-identity==1.16.1"
pip install "langfuse==2.45.0"
pip install "langfuse==2.60.4"
pip install "logfire==0.29.0"
pip install numpydoc
pip install traceloop-sdk==0.21.1
Expand Down
8 changes: 8 additions & 0 deletions litellm/integrations/langfuse/langfuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@ def _log_langfuse_v2( # noqa: PLR0915
"version": clean_metadata.pop("version", None),
}

# Promote every metadata entry whose key starts with "generation_"
for key in list(
filter(lambda k: k.startswith("generation_"), clean_metadata.keys())
):
stripped = key.replace("generation_", "")
if stripped not in generation_params:
generation_params[stripped] = clean_metadata[key]

parent_observation_id = metadata.get("parent_observation_id", None)
if parent_observation_id is not None:
generation_params["parent_observation_id"] = parent_observation_id
Expand Down
2 changes: 1 addition & 1 deletion litellm/proxy/example_config_yaml/oai_misc_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ litellm_settings:
failure_callback: ["langfuse"]
langfuse_public_key: os.environ/LANGFUSE_PROJECT2_PUBLIC # Project 2
langfuse_secret: os.environ/LANGFUSE_PROJECT2_SECRET # Project 2
langfuse_host: https://us.cloud.langfuse.com
langfuse_host: https://cloud.langfuse.com

# For /fine_tuning/jobs endpoints
finetune_settings:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ anthropic[vertex]==0.21.3
mcp==1.5.0 # for MCP server
google-generativeai==0.5.0 # for vertex ai calls
async_generator==1.10.0 # for async ollama calls
langfuse==2.45.0 # for langfuse self-hosted logging
langfuse==2.60.4 # for langfuse self-hosted logging
prometheus_client==0.20.0 # for /metrics endpoint on proxy
ddtrace==2.19.0 # for advanced DD tracing / profiling
orjson==3.10.12 # fast /embedding responses
Expand Down
2 changes: 1 addition & 1 deletion tests/local_testing/test_pass_through_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ async def test_aaapass_through_endpoint_pass_through_keys_langfuse(
pass_through_endpoints = [
{
"path": "/api/public/ingestion",
"target": "https://us.cloud.langfuse.com/api/public/ingestion",
"target": "https://cloud.langfuse.com/api/public/ingestion",
"auth": auth,
"custom_auth_parser": "langfuse",
"headers": {
Expand Down
2 changes: 1 addition & 1 deletion tests/logging_callback_tests/test_langfuse_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def _verify_langfuse_call(
print(f"URL: {url}")
print(f"Request Body: {json.dumps(actual_request_body, indent=4)}")

assert url == "https://us.cloud.langfuse.com/api/public/ingestion"
assert url == "https://cloud.langfuse.com/api/public/ingestion"
assert_langfuse_request_matches_expected(
actual_request_body,
expected_file_name,
Expand Down
4 changes: 2 additions & 2 deletions tests/proxy_unit_tests/test_proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ async def test_add_callback_via_key(prisma_client):
"callback_vars": {
"langfuse_public_key": "os.environ/LANGFUSE_PUBLIC_KEY",
"langfuse_secret_key": "os.environ/LANGFUSE_SECRET_KEY",
"langfuse_host": "https://us.cloud.langfuse.com",
"langfuse_host": "https://cloud.langfuse.com",
},
}
]
Expand Down Expand Up @@ -1451,7 +1451,7 @@ async def test_add_callback_via_key_litellm_pre_call_utils(
"callback_vars": {
"langfuse_public_key": "my-mock-public-key",
"langfuse_secret_key": "my-mock-secret-key",
"langfuse_host": "https://us.cloud.langfuse.com",
"langfuse_host": "https://cloud.langfuse.com",
},
}
]
Expand Down
4 changes: 2 additions & 2 deletions tests/proxy_unit_tests/test_proxy_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async def test_add_key_or_team_level_spend_logs_metadata_to_request(
"callback_vars",
[
{
"langfuse_host": "https://us.cloud.langfuse.com",
"langfuse_host": "https://cloud.langfuse.com",
"langfuse_public_key": "pk-lf-9636b7a6-c066",
"langfuse_secret_key": "sk-lf-7cc8b620",
},
Expand All @@ -231,7 +231,7 @@ async def test_add_key_or_team_level_spend_logs_metadata_to_request(
def test_dynamic_logging_metadata_key_and_team_metadata(callback_vars):
os.environ["LANGFUSE_PUBLIC_KEY_TEMP"] = "pk-lf-9636b7a6-c066"
os.environ["LANGFUSE_SECRET_KEY_TEMP"] = "sk-lf-7cc8b620"
os.environ["LANGFUSE_HOST_TEMP"] = "https://us.cloud.langfuse.com"
os.environ["LANGFUSE_HOST_TEMP"] = "https://cloud.langfuse.com"
from litellm.proxy.proxy_server import ProxyConfig

proxy_config = ProxyConfig()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_team_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def test_aaateam_logging():
langfuse_client = langfuse.Langfuse(
public_key=os.getenv("LANGFUSE_PROJECT1_PUBLIC"),
secret_key=os.getenv("LANGFUSE_PROJECT1_SECRET"),
host="https://us.cloud.langfuse.com",
host="https://cloud.langfuse.com",
)

await asyncio.sleep(30)
Expand Down Expand Up @@ -128,7 +128,7 @@ async def test_team_2logging():
print(f"langfuse_public_key: {langfuse_public_key}")
langfuse_secret_key = os.getenv("LANGFUSE_PROJECT2_SECRET")
print(f"langfuse_secret_key: {langfuse_secret_key}")
langfuse_host = "https://us.cloud.langfuse.com"
langfuse_host = "https://cloud.langfuse.com"

try:
assert langfuse_public_key is not None
Expand Down Expand Up @@ -181,7 +181,7 @@ async def test_team_2logging():
langfuse_client_1 = langfuse.Langfuse(
public_key=os.getenv("LANGFUSE_PROJECT1_PUBLIC"),
secret_key=os.getenv("LANGFUSE_PROJECT1_SECRET"),
host="https://us.cloud.langfuse.com",
host="https://cloud.langfuse.com",
)

generations_team_1 = langfuse_client_1.get_generations(
Expand Down
Loading