Commit 31dfbeb
Cap max_tokens per-model so gpt-4o translation doesn't 400
Translation passes a max_tokens budget of len(text) * 3, which for a
9k-char section comes out to ~27k tokens — above gpt-4o's 16384 max
completion cap. Adds _MODEL_MAX_COMPLETION and _cap_tokens() to clamp
the request, fixing the "max_tokens is too large" 400 error that
crashed note_generation on the first Chinese section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d65f3c1 commit 31dfbeb
1 file changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
541 | 566 | | |
542 | 567 | | |
543 | 568 | | |
544 | 569 | | |
545 | 570 | | |
546 | 571 | | |
547 | 572 | | |
| 573 | + | |
548 | 574 | | |
549 | 575 | | |
550 | 576 | | |
| |||
0 commit comments