Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje committed Oct 1, 2024
1 parent 2ed1e0d commit cc16608
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion integrations/langfuse/tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def test_tracing_integration(llm_class, env_var, expected_trace):
ChatMessage.from_user("Tell me about {{location}}"),
]

response = pipe.run(data={"prompt_builder": {"template_variables": {"location": "Berlin"}, "template": messages}})
response = pipe.run(
data={
"prompt_builder": {"template_variables": {"location": "Berlin"}, "template": messages},
"tracer": {"invocation_context": {"user_id": "user_42"}},
}
)
assert "Berlin" in response["llm"]["replies"][0].content
assert response["tracer"]["trace_url"]

Expand All @@ -65,5 +70,7 @@ def test_tracing_integration(llm_class, env_var, expected_trace):
assert expected_trace in str(response.content)
# check if the trace contains the expected generation span
assert "GENERATION" in str(response.content)
# check if the trace contains the expected user_id
assert "user_42" in str(response.content)
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to retrieve data from Langfuse API: {e}")

0 comments on commit cc16608

Please sign in to comment.