Commit 14d1d0b
fix(llma): extract model from response for OpenAI stored prompts (#395)
* fix: extract model from response for OpenAI stored prompts
When using OpenAI stored prompts, the model is defined in the OpenAI
dashboard rather than passed in the API request. This change adds a
fallback to extract the model from the response object when not
provided in kwargs.
Fixes PostHog/posthog#42861
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
* 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]>
* style: format utils.py with ruff
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* fix: remove 'unknown' fallback from non-streaming to match original behavior
Non-streaming originally returned None when model wasn't in kwargs.
Streaming keeps "unknown" fallback as that was the original behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* test: add test for None model fallback in non-streaming
Verifies that non-streaming returns None (not "unknown") when model
is not available in kwargs or response, matching original behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
---------
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>1 parent 80e6e43 commit 14d1d0b
File tree
6 files changed
+519
-7
lines changed- posthog
- ai
- openai
- test/ai/openai
6 files changed
+519
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| |||
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| 173 | + | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
| |||
177 | 187 | | |
178 | 188 | | |
179 | 189 | | |
| 190 | + | |
180 | 191 | | |
181 | 192 | | |
182 | 193 | | |
| |||
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
192 | 206 | | |
193 | 207 | | |
194 | | - | |
| 208 | + | |
195 | 209 | | |
196 | 210 | | |
197 | 211 | | |
| |||
320 | 334 | | |
321 | 335 | | |
322 | 336 | | |
| 337 | + | |
323 | 338 | | |
324 | 339 | | |
325 | 340 | | |
| |||
329 | 344 | | |
330 | 345 | | |
331 | 346 | | |
| 347 | + | |
332 | 348 | | |
333 | 349 | | |
334 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
335 | 355 | | |
336 | 356 | | |
337 | 357 | | |
| |||
376 | 396 | | |
377 | 397 | | |
378 | 398 | | |
| 399 | + | |
379 | 400 | | |
380 | 401 | | |
381 | 402 | | |
| |||
393 | 414 | | |
394 | 415 | | |
395 | 416 | | |
| 417 | + | |
396 | 418 | | |
397 | 419 | | |
398 | 420 | | |
| |||
405 | 427 | | |
406 | 428 | | |
407 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
408 | 433 | | |
409 | 434 | | |
410 | | - | |
| 435 | + | |
411 | 436 | | |
412 | 437 | | |
413 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
| 178 | + | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
| |||
182 | 192 | | |
183 | 193 | | |
184 | 194 | | |
| 195 | + | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
188 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
189 | 203 | | |
190 | 204 | | |
191 | | - | |
| 205 | + | |
192 | 206 | | |
193 | 207 | | |
194 | 208 | | |
| |||
350 | 364 | | |
351 | 365 | | |
352 | 366 | | |
| 367 | + | |
353 | 368 | | |
354 | 369 | | |
355 | 370 | | |
| |||
360 | 375 | | |
361 | 376 | | |
362 | 377 | | |
| 378 | + | |
363 | 379 | | |
364 | 380 | | |
365 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
366 | 386 | | |
367 | 387 | | |
368 | 388 | | |
| |||
405 | 425 | | |
406 | 426 | | |
407 | 427 | | |
| 428 | + | |
408 | 429 | | |
409 | 430 | | |
410 | 431 | | |
| |||
422 | 443 | | |
423 | 444 | | |
424 | 445 | | |
| 446 | + | |
425 | 447 | | |
426 | 448 | | |
427 | 449 | | |
428 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
429 | 454 | | |
430 | 455 | | |
431 | | - | |
| 456 | + | |
432 | 457 | | |
433 | 458 | | |
434 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
0 commit comments