Commit af228ad
authored
Add 0092 embed chunk-and-stitch (TEI + shared helper) (#217)
* Add 0092 embed chunk-and-stitch
Implement the general section 8 embed batch-chunking rule and TEI /embed
chunk-and-stitch (fixture 038). TeiEmbeddingProvider.embed() now chunks by
its chunk_size (TEI's max-client-batch-size) over consecutive slices,
concatenates vectors in input order, and produces usage null / response_id
null (TEI reports neither).
Lift the shared chunk_and_stitch_embed helper into retrieval/_wire.py: the
loop, per-chunk count validation, input-order concat, None-aware
input_tokens sum, first-chunk response_id, and section 4 validation, driven
by a per-mapping embed_chunk closure. TEI /embed and Cohere /v2/embed both
adopt it; Cohere's own chunk path migrates onto it unchanged. Un-defer
fixture 038 and flip conformance.toml.
* Guard chunk_and_stitch_embed against a non-positive cap
The shared helper assumed cap was positive; a cap <= 0 (a caller
misconfiguration) surfaced as a raw range() error (0) or a misleading
empty-stitch validation failure (< 0). Raise ValueError eagerly with a
clear message, mirroring the chunk_size guard TeiEmbeddingProvider
already applies at construction.
* Validate input in chunk_and_stitch_embed
An empty input reaching the shared helper fell through to
validate_embedding_response and raised provider_invalid_response
("provider returned no vectors"), misclassifying a caller-side invalid
request as an invalid response. Call validate_embedding_input up front so
an empty (or non-string) input raises provider_invalid_request. Providers
already validate before the helper; this protects a direct/future caller.
* Fix an inaccurate comment in chunk_and_stitch_embed
The up-front validate_embedding_input() comment claimed the guard
covers empty and non-string inputs, but the validator only rejects an
empty list. Drop the non-string claim so the comment matches the code.1 parent c66a1d9 commit af228ad
7 files changed
Lines changed: 348 additions & 98 deletions
File tree
- src/openarmature/retrieval
- providers
- tests
- conformance
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
883 | 883 | | |
884 | 884 | | |
885 | 885 | | |
886 | | - | |
887 | | - | |
888 | | - | |
| 886 | + | |
889 | 887 | | |
890 | | - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
891 | 891 | | |
892 | 892 | | |
893 | 893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
85 | 173 | | |
86 | 174 | | |
87 | 175 | | |
| |||
109 | 197 | | |
110 | 198 | | |
111 | 199 | | |
| 200 | + | |
112 | 201 | | |
113 | 202 | | |
114 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
77 | | - | |
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
| |||
622 | 620 | | |
623 | 621 | | |
624 | 622 | | |
| 623 | + | |
625 | 624 | | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
639 | 637 | | |
640 | 638 | | |
641 | 639 | | |
642 | 640 | | |
643 | 641 | | |
644 | 642 | | |
645 | 643 | | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
675 | 648 | | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
| 649 | + | |
| 650 | + | |
680 | 651 | | |
681 | 652 | | |
682 | 653 | | |
| |||
0 commit comments