@singlestore/elegance-sdk
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -133,2 +133,3 @@ import * as react from 'react'; | ||
query: string; | ||
queryEmbedding?: Embedding; | ||
embeddingField: string; | ||
@@ -135,0 +136,0 @@ limit?: number; |
{ | ||
"name": "@singlestore/elegance-sdk", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -167,2 +167,3 @@ import { ClientOptions } from 'openai'; | ||
query: string; | ||
queryEmbedding?: Embedding; | ||
embeddingField: string; | ||
@@ -169,0 +170,0 @@ limit?: number; |
@@ -408,6 +408,15 @@ 'use strict'; | ||
let result = void 0; | ||
const { db, collection, embeddingField, query, minSimilarity = 0, limit, includeEmbedding = false } = body; | ||
const queryEmbedding = (yield ai.createEmbedding(query))[0]; | ||
const { | ||
db, | ||
collection, | ||
embeddingField, | ||
query, | ||
queryEmbedding, | ||
minSimilarity = 0, | ||
limit, | ||
includeEmbedding = false | ||
} = body; | ||
const _queryEmbedding = queryEmbedding != null ? queryEmbedding : (yield ai.createEmbedding(query))[0]; | ||
if (connection.type === "kai") { | ||
const queryBuffer = ai.embeddingToBuffer(queryEmbedding); | ||
const queryBuffer = ai.embeddingToBuffer(_queryEmbedding); | ||
const query2 = [ | ||
@@ -430,3 +439,3 @@ { $addFields: { similarity: { $dotProduct: [`$${embeddingField}`, queryBuffer] } } } | ||
let query2 = ` | ||
SELECT *, DOT_PRODUCT(${embeddingField}, JSON_ARRAY_PACK('[${queryEmbedding}]')) AS similarity | ||
SELECT *, DOT_PRODUCT(${embeddingField}, JSON_ARRAY_PACK('[${_queryEmbedding}]')) AS similarity | ||
FROM ${tablePath} | ||
@@ -433,0 +442,0 @@ WHERE similarity > ${minSimilarity} |
@@ -169,2 +169,3 @@ import { ClientOptions } from 'openai'; | ||
query: string; | ||
queryEmbedding?: Embedding; | ||
embeddingField: string; | ||
@@ -171,0 +172,0 @@ limit?: number; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121470
2721