File tree Expand file tree Collapse file tree 8 files changed +169
-9
lines changed
server/utils/vectorDbProviders Expand file tree Collapse file tree 8 files changed +169
-9
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,27 @@ const AstraDB = {
268268 } ;
269269 }
270270
271- const queryVector = await LLMConnector . embedTextInput ( input ) ;
271+ let textInput = "" ;
272+ if ( typeof input === "string" || input instanceof String ) {
273+ textInput = input ;
274+ } else if ( Array . isArray ( input ) ) {
275+ textInput = input . map ( ( x ) => {
276+ if ( typeof x === "string" || x instanceof String ) {
277+ return x + "\n" ;
278+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
279+ return x . text + "\n" ;
280+ } else {
281+ return "" ;
282+ }
283+ } ) ;
284+ } else {
285+ return {
286+ contextTexts : [ ] ,
287+ sources : [ ] ,
288+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
289+ } ;
290+ }
291+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
272292 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
273293 client,
274294 namespace,
Original file line number Diff line number Diff line change @@ -355,7 +355,27 @@ const Chroma = {
355355 } ;
356356 }
357357
358- const queryVector = await LLMConnector . embedTextInput ( input ) ;
358+ let textInput = "" ;
359+ if ( typeof input === "string" || input instanceof String ) {
360+ textInput = input ;
361+ } else if ( Array . isArray ( input ) ) {
362+ textInput = input . map ( ( x ) => {
363+ if ( typeof x === "string" || x instanceof String ) {
364+ return x + "\n" ;
365+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
366+ return x . text + "\n" ;
367+ } else {
368+ return "" ;
369+ }
370+ } ) ;
371+ } else {
372+ return {
373+ contextTexts : [ ] ,
374+ sources : [ ] ,
375+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
376+ } ;
377+ }
378+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
359379 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
360380 client,
361381 namespace,
Original file line number Diff line number Diff line change @@ -400,12 +400,32 @@ const LanceDb = {
400400 } ;
401401 }
402402
403- const queryVector = await LLMConnector . embedTextInput ( input ) ;
403+ let textInput = "" ;
404+ if ( typeof input === "string" || input instanceof String ) {
405+ textInput = input ;
406+ } else if ( Array . isArray ( input ) ) {
407+ textInput = input . map ( ( x ) => {
408+ if ( typeof x === "string" || x instanceof String ) {
409+ return x + "\n" ;
410+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
411+ return x . text + "\n" ;
412+ } else {
413+ return "" ;
414+ }
415+ } ) ;
416+ } else {
417+ return {
418+ contextTexts : [ ] ,
419+ sources : [ ] ,
420+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
421+ } ;
422+ }
423+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
404424 const result = rerank
405425 ? await this . rerankedSimilarityResponse ( {
406426 client,
407427 namespace,
408- query : input ,
428+ query : textInput ,
409429 queryVector,
410430 similarityThreshold,
411431 topN,
Original file line number Diff line number Diff line change @@ -311,7 +311,27 @@ const Milvus = {
311311 } ;
312312 }
313313
314- const queryVector = await LLMConnector . embedTextInput ( input ) ;
314+ let textInput = "" ;
315+ if ( typeof input === "string" || input instanceof String ) {
316+ textInput = input ;
317+ } else if ( Array . isArray ( input ) ) {
318+ textInput = input . map ( ( x ) => {
319+ if ( typeof x === "string" || x instanceof String ) {
320+ return x + "\n" ;
321+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
322+ return x . text + "\n" ;
323+ } else {
324+ return "" ;
325+ }
326+ } ) ;
327+ } else {
328+ return {
329+ contextTexts : [ ] ,
330+ sources : [ ] ,
331+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
332+ } ;
333+ }
334+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
315335 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
316336 client,
317337 namespace,
Original file line number Diff line number Diff line change @@ -253,7 +253,27 @@ const PineconeDB = {
253253 "Invalid namespace - has it been collected and populated yet?"
254254 ) ;
255255
256- const queryVector = await LLMConnector . embedTextInput ( input ) ;
256+ let textInput = "" ;
257+ if ( typeof input === "string" || input instanceof String ) {
258+ textInput = input ;
259+ } else if ( Array . isArray ( input ) ) {
260+ textInput = input . map ( ( x ) => {
261+ if ( typeof x === "string" || x instanceof String ) {
262+ return x + "\n" ;
263+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
264+ return x . text + "\n" ;
265+ } else {
266+ return "" ;
267+ }
268+ } ) ;
269+ } else {
270+ return {
271+ contextTexts : [ ] ,
272+ sources : [ ] ,
273+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
274+ } ;
275+ }
276+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
257277 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
258278 client : pineconeIndex ,
259279 namespace,
Original file line number Diff line number Diff line change @@ -336,7 +336,27 @@ const QDrant = {
336336 } ;
337337 }
338338
339- const queryVector = await LLMConnector . embedTextInput ( input ) ;
339+ let textInput = "" ;
340+ if ( typeof input === "string" || input instanceof String ) {
341+ textInput = input ;
342+ } else if ( Array . isArray ( input ) ) {
343+ textInput = input . map ( ( x ) => {
344+ if ( typeof x === "string" || x instanceof String ) {
345+ return x + "\n" ;
346+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
347+ return x . text + "\n" ;
348+ } else {
349+ return "" ;
350+ }
351+ } ) ;
352+ } else {
353+ return {
354+ contextTexts : [ ] ,
355+ sources : [ ] ,
356+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
357+ } ;
358+ }
359+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
340360 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
341361 client,
342362 namespace,
Original file line number Diff line number Diff line change @@ -380,7 +380,27 @@ const Weaviate = {
380380 } ;
381381 }
382382
383- const queryVector = await LLMConnector . embedTextInput ( input ) ;
383+ let textInput = "" ;
384+ if ( typeof input === "string" || input instanceof String ) {
385+ textInput = input ;
386+ } else if ( Array . isArray ( input ) ) {
387+ textInput = input . map ( ( x ) => {
388+ if ( typeof x === "string" || x instanceof String ) {
389+ return x + "\n" ;
390+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
391+ return x . text + "\n" ;
392+ } else {
393+ return "" ;
394+ }
395+ } ) ;
396+ } else {
397+ return {
398+ contextTexts : [ ] ,
399+ sources : [ ] ,
400+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
401+ } ;
402+ }
403+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
384404 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
385405 client,
386406 namespace,
Original file line number Diff line number Diff line change @@ -304,7 +304,27 @@ const Zilliz = {
304304 } ;
305305 }
306306
307- const queryVector = await LLMConnector . embedTextInput ( input ) ;
307+ let textInput = "" ;
308+ if ( typeof input === "string" || input instanceof String ) {
309+ textInput = input ;
310+ } else if ( Array . isArray ( input ) ) {
311+ textInput = input . map ( ( x ) => {
312+ if ( typeof x === "string" || x instanceof String ) {
313+ return x + "\n" ;
314+ } else if ( typeof x . text === "string" || x . text instanceof String ) {
315+ return x . text + "\n" ;
316+ } else {
317+ return "" ;
318+ }
319+ } ) ;
320+ } else {
321+ return {
322+ contextTexts : [ ] ,
323+ sources : [ ] ,
324+ message : `Invalid query - the type of input is not string but ${ typeof input } !` ,
325+ } ;
326+ }
327+ const queryVector = await LLMConnector . embedTextInput ( textInput ) ;
308328 const { contextTexts, sourceDocuments } = await this . similarityResponse ( {
309329 client,
310330 namespace,
You can’t perform that action at this time.
0 commit comments