Commit 97ef2d1
committed
feat(anthropic): add 5 translation improvements from reference
1. Session ID for Prompt Caching (High Priority)
- Derive stable session ID from first user message hash
- Enables prompt caching continuity across conversation turns
- Falls back to random ID if no user message found
2. Content Reordering (Medium Priority)
- Reorder assistant content blocks: thinking → text → tool_use
- Matches Anthropic's expected ordering
- Sanitizes thinking blocks by removing cache_control
3. Document/PDF Handling (Low Priority)
- Support for 'document' type content blocks
- Converts base64/URL documents to OpenAI image_url format
- Default media type: application/pdf
4. Gemini Output Token Cap (Low Priority)
- Add GEMINI_MAX_OUTPUT_TOKENS constant (16384)
- Cap maxOutputTokens for non-Claude models
- Prevents errors from exceeding Gemini limits
5. Schema Sanitization Improvements (Low Priority)
- Add _score_schema_option() for smarter anyOf/oneOf selection
- Add _merge_all_of() to properly merge allOf schemas
- Add description hints when flattening union types
- Select best option (objects > arrays > primitives > null)1 parent b81ca57 commit 97ef2d1
File tree
2 files changed
+387
-13
lines changed- src/rotator_library
- anthropic_compat
- providers
2 files changed
+387
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
18 | 69 | | |
19 | 70 | | |
20 | 71 | | |
| |||
55 | 106 | | |
56 | 107 | | |
57 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
58 | 114 | | |
59 | 115 | | |
60 | 116 | | |
| |||
88 | 144 | | |
89 | 145 | | |
90 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
91 | 167 | | |
92 | 168 | | |
93 | 169 | | |
| |||
0 commit comments