8383
8484 expect ( topics_schema . find_by_target ( topic ) . updated_at ) . to eq_time ( original_vector_gen )
8585 end
86+
87+ context "when one of the concurrently generated embeddings fails" do
88+ it "still processes the succesful ones" do
89+ text = vdef . prepare_target_text ( topic )
90+
91+ text2 = vdef . prepare_target_text ( topic_2 )
92+
93+ stub_vector_mapping ( text , expected_embedding_1 )
94+ stub_vector_mapping ( text2 , expected_embedding_2 , result_status : 429 )
95+
96+ vector . gen_bulk_reprensentations ( Topic . where ( id : [ topic . id , topic_2 . id ] ) )
97+
98+ expect ( topics_schema . find_by_embedding ( expected_embedding_1 ) . topic_id ) . to eq ( topic . id )
99+ expect ( topics_schema . find_by_target ( topic_2 ) ) . to be_nil
100+ end
101+ end
86102 end
87103 end
88104
89105 context "with open_ai as the provider" do
90106 fab! ( :vdef ) { Fabricate ( :open_ai_embedding_def ) }
91107
92- def stub_vector_mapping ( text , expected_embedding )
108+ def stub_vector_mapping ( text , expected_embedding , result_status : 200 )
93109 EmbeddingsGenerationStubs . openai_service (
94110 vdef . lookup_custom_param ( "model_name" ) ,
95111 text ,
96112 expected_embedding ,
113+ result_status : result_status ,
97114 )
98115 end
99116
@@ -123,8 +140,12 @@ def stub_vector_mapping(text, expected_embedding)
123140 context "with hugging_face as the provider" do
124141 fab! ( :vdef ) { Fabricate ( :embedding_definition ) }
125142
126- def stub_vector_mapping ( text , expected_embedding )
127- EmbeddingsGenerationStubs . hugging_face_service ( text , expected_embedding )
143+ def stub_vector_mapping ( text , expected_embedding , result_status : 200 )
144+ EmbeddingsGenerationStubs . hugging_face_service (
145+ text ,
146+ expected_embedding ,
147+ result_status : result_status ,
148+ )
128149 end
129150
130151 it_behaves_like "generates and store embeddings using a vector definition"
@@ -133,8 +154,13 @@ def stub_vector_mapping(text, expected_embedding)
133154 context "with google as the provider" do
134155 fab! ( :vdef ) { Fabricate ( :gemini_embedding_def ) }
135156
136- def stub_vector_mapping ( text , expected_embedding )
137- EmbeddingsGenerationStubs . gemini_service ( vdef . api_key , text , expected_embedding )
157+ def stub_vector_mapping ( text , expected_embedding , result_status : 200 )
158+ EmbeddingsGenerationStubs . gemini_service (
159+ vdef . api_key ,
160+ text ,
161+ expected_embedding ,
162+ result_status : result_status ,
163+ )
138164 end
139165
140166 it_behaves_like "generates and store embeddings using a vector definition"
@@ -143,8 +169,12 @@ def stub_vector_mapping(text, expected_embedding)
143169 context "with cloudflare as the provider" do
144170 fab! ( :vdef ) { Fabricate ( :cloudflare_embedding_def ) }
145171
146- def stub_vector_mapping ( text , expected_embedding )
147- EmbeddingsGenerationStubs . cloudflare_service ( text , expected_embedding )
172+ def stub_vector_mapping ( text , expected_embedding , result_status : 200 )
173+ EmbeddingsGenerationStubs . cloudflare_service (
174+ text ,
175+ expected_embedding ,
176+ result_status : result_status ,
177+ )
148178 end
149179
150180 it_behaves_like "generates and store embeddings using a vector definition"
0 commit comments