diff --git a/posthog/ai/langchain/callbacks.py b/posthog/ai/langchain/callbacks.py index c244e85e..1922f787 100644 --- a/posthog/ai/langchain/callbacks.py +++ b/posthog/ai/langchain/callbacks.py @@ -486,6 +486,7 @@ def _capture_trace_or_span( "$ai_latency": run.latency, "$ai_span_name": run.name, "$ai_span_id": run_id, + "$ai_framework": "langchain", } if parent_run_id is not None: event_properties["$ai_parent_id"] = parent_run_id @@ -556,6 +557,7 @@ def _capture_generation( "$ai_http_status": 200, "$ai_latency": run.latency, "$ai_base_url": run.base_url, + "$ai_framework": "langchain", } if run.tools: diff --git a/posthog/test/ai/langchain/test_callbacks.py b/posthog/test/ai/langchain/test_callbacks.py index ad4c049b..b6e74e6b 100644 --- a/posthog/test/ai/langchain/test_callbacks.py +++ b/posthog/test/ai/langchain/test_callbacks.py @@ -204,6 +204,7 @@ def test_basic_chat_chain(mock_client, stream): # Generation is second assert generation_args["event"] == "$ai_generation" assert "distinct_id" in generation_args + assert generation_props["$ai_framework"] == "langchain" assert "$ai_model" in generation_props assert "$ai_provider" in generation_props assert generation_props["$ai_input"] == [