Commit 5d27110
committed
fix: correct buffer handling for base64 embedding decoding
- Fixed unsafe buffer handling that could cause dimension truncation
- Use DataView with proper byte order handling for Float32Array conversion
- This prevents reading beyond buffer boundaries and data corruption
- Affects all models using base64 encoding, not just Gemini
The previous implementation used buffer.buffer directly which could:
1. Read from wrong memory locations if buffer was a view
2. Cause dimension truncation for large embeddings (like 3072-dim)
3. Result in incorrect embedding values
Fixes #73481 parent 32fc3d6 commit 5d27110
1 file changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
282 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| |||
0 commit comments