Skip to content

Commit abda458

Browse files
andrewm4894claude
andcommitted
test: add tests for model extraction fallback and bump to 7.4.1
- Add 8 tests covering model extraction from response for stored prompts - Fix utils.py to add 'unknown' fallback for consistency - Bump version to 7.4.1 - Update CHANGELOG.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c4f8230 commit abda458

File tree

4 files changed

+419
-3
lines changed

4 files changed

+419
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 7.4.1 - 2025-12-19
2+
3+
fix: extract model from response for OpenAI stored prompts
4+
5+
When using OpenAI stored prompts, the model is defined in the OpenAI dashboard rather than passed in the API request. This fix adds a fallback to extract the model from the response object when not provided in kwargs, ensuring generations show up with the correct model and enabling cost calculations.
6+
17
# 7.4.0 - 2025-12-16
28

39
feat: Add automatic retries for feature flag requests

posthog/ai/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def call_llm_and_track_usage(
285285

286286
event_properties = {
287287
"$ai_provider": provider,
288-
"$ai_model": kwargs.get("model") or getattr(response, "model", None),
288+
"$ai_model": kwargs.get("model") or getattr(response, "model", None) or "unknown",
289289
"$ai_model_parameters": get_model_params(kwargs),
290290
"$ai_input": with_privacy_mode(
291291
ph_client, posthog_privacy_mode, sanitized_messages
@@ -396,7 +396,7 @@ async def call_llm_and_track_usage_async(
396396

397397
event_properties = {
398398
"$ai_provider": provider,
399-
"$ai_model": kwargs.get("model") or getattr(response, "model", None),
399+
"$ai_model": kwargs.get("model") or getattr(response, "model", None) or "unknown",
400400
"$ai_model_parameters": get_model_params(kwargs),
401401
"$ai_input": with_privacy_mode(
402402
ph_client, posthog_privacy_mode, sanitized_messages

0 commit comments

Comments
 (0)