Skip to content

Commit b332403

Browse files
andrewm4894claude
andcommitted
Add $ai_lib_metadata assertions to provider tests
Add missing $ai_lib_metadata assertions to Anthropic, Gemini, and LangChain tests to match the validation already present in OpenAI tests. Each test now verifies the metadata field contains the correct schema version and framework name. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 034df7c commit b332403

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

posthog/test/ai/anthropic/test_anthropic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ def test_basic_completion(mock_client, mock_anthropic_response):
293293

294294
assert call_args["distinct_id"] == "test-id"
295295
assert call_args["event"] == "$ai_generation"
296+
assert props["$ai_lib_metadata"] == {
297+
"schema": "v1",
298+
"frameworks": [{"name": "anthropic"}],
299+
}
296300
assert props["$ai_provider"] == "anthropic"
297301
assert props["$ai_model"] == "claude-3-opus-20240229"
298302
assert props["$ai_input"] == [{"role": "user", "content": "Hello"}]

posthog/test/ai/gemini/test_gemini.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ def test_new_client_basic_generation(
167167

168168
assert call_args["distinct_id"] == "test-id"
169169
assert call_args["event"] == "$ai_generation"
170+
assert props["$ai_lib_metadata"] == {
171+
"schema": "v1",
172+
"frameworks": [{"name": "gemini"}],
173+
}
170174
assert props["$ai_provider"] == "gemini"
171175
assert props["$ai_model"] == "gemini-2.0-flash"
172176
assert props["$ai_input_tokens"] == 20

posthog/test/ai/langchain/test_callbacks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ def test_basic_chat_chain(mock_client, stream):
204204
# Generation is second
205205
assert generation_args["event"] == "$ai_generation"
206206
assert "distinct_id" in generation_args
207+
assert generation_props["$ai_lib_metadata"] == {
208+
"schema": "v1",
209+
"frameworks": [{"name": "langchain"}],
210+
}
207211
assert "$ai_model" in generation_props
208212
assert "$ai_provider" in generation_props
209213
assert generation_props["$ai_input"] == [

0 commit comments

Comments
 (0)