@singlestore/elegance-sdk
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -133,4 +133,4 @@ import * as react from 'react'; | ||
} & Omit<CreateChatCompletionBody, "prompt">>; | ||
type VectorSearchResult = any[]; | ||
type VectorSearchBody = WithDb<{ | ||
type DotProductSearchResult = any[]; | ||
type DotProductSearchBody = WithDb<{ | ||
query: string; | ||
@@ -192,3 +192,3 @@ queryEmbedding?: Embedding; | ||
searchChatCompletion: <R_10 extends SearchChatCompletionResult = SearchChatCompletionResult>(body: SearchChatCompletionBody, init?: RequestInit$1 | undefined) => Promise<R_10>; | ||
vectorSearch: <R_11 extends VectorSearchResult = VectorSearchResult>(body: VectorSearchBody, init?: RequestInit$1 | undefined) => Promise<R_11>; | ||
dotProductSearch: <R_11 extends DotProductSearchResult = DotProductSearchResult>(body: DotProductSearchBody, init?: RequestInit$1 | undefined) => Promise<R_11>; | ||
}; | ||
@@ -304,3 +304,3 @@ hooks: { | ||
}; | ||
useVectorSearch: <R_23 extends VectorSearchResult = VectorSearchResult>(options?: UseRequestOptions<R_23> | undefined) => { | ||
useDotProductSearch: <R_23 extends DotProductSearchResult = DotProductSearchResult>(options?: UseRequestOptions<R_23> | undefined) => { | ||
value: Awaited<R_23> | undefined; | ||
@@ -312,3 +312,3 @@ error: DefaultError | undefined; | ||
setIsLoading: react.Dispatch<react.SetStateAction<boolean>>; | ||
execute: (body: VectorSearchBody, init?: RequestInit$1 | undefined) => Promise<Awaited<R_23> | undefined>; | ||
execute: (body: DotProductSearchBody, init?: RequestInit$1 | undefined) => Promise<Awaited<R_23> | undefined>; | ||
}; | ||
@@ -315,0 +315,0 @@ }; |
@@ -143,4 +143,4 @@ 'use strict'; | ||
}, | ||
useVectorSearch: (options) => { | ||
return useRequest(requests.vectorSearch, options); | ||
useDotProductSearch: (options) => { | ||
return useRequest(requests.dotProductSearch, options); | ||
} | ||
@@ -197,3 +197,6 @@ }; | ||
const _fetch = (route, body, init) => { | ||
return fetcher(route, __spreadProps(__spreadValues({}, init), { method: "POST", body: JSON.stringify(body) })); | ||
return fetcher(route, __spreadProps(__spreadValues({}, init), { | ||
method: "POST", | ||
body: JSON.stringify(body) | ||
})); | ||
}; | ||
@@ -233,4 +236,4 @@ return { | ||
}, | ||
vectorSearch: (body, init) => { | ||
return _fetch("/vectorSearch", body, init); | ||
dotProductSearch: (body, init) => { | ||
return _fetch("/dotProductSearch", body, init); | ||
} | ||
@@ -237,0 +240,0 @@ }; |
{ | ||
"name": "@singlestore/elegance-sdk", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -7,3 +7,3 @@ # SingleStore Elegance SDK | ||
- Vector search | ||
- Dot product search | ||
- Chat completions | ||
@@ -118,3 +118,3 @@ - File embeddings generation (csv, pdf) | ||
export const eleganceClient = createEleganceClient("mysql", { | ||
baseURL: "http://localhost:4000" | ||
baseURL: "http://localhost:4000", | ||
}); | ||
@@ -130,3 +130,6 @@ ``` | ||
export function ExampleComponent() { | ||
const query = eleganceClient.hooks.useQuery<{ name: string }[]>({ initialValue: [], initialIsLoading: true }); | ||
const query = eleganceClient.hooks.useQuery<{ name: string }[]>({ | ||
initialValue: [], | ||
initialIsLoading: true, | ||
}); | ||
const { execute: executeQuery } = query; | ||
@@ -142,3 +145,3 @@ | ||
<div> | ||
{query.value.map(item => ( | ||
{query.value.map((item) => ( | ||
<h4 key={item.name}>{item.name}</h4> | ||
@@ -496,3 +499,3 @@ ))} | ||
Accepts a prompt, performs vector search, and creates chat completion for the found records. | ||
Accepts a prompt, performs dot product search, and creates chat completion for the found records. | ||
@@ -527,5 +530,5 @@ **Parameters:** | ||
#### eleganceServerClient.controllers.vectorSearch | ||
#### eleganceServerClient.controllers.dotProductSearch | ||
Performs vector search in the collection based on the query. | ||
Performs dot product search in the collection based on the query. | ||
@@ -648,3 +651,7 @@ **Parameters:** | ||
```tsx | ||
<R = any,>(options?: { initialValue?: R; initialIsLoading?: boolean; onError?: (error: DefaultError) => void }) => { | ||
<R = any,>(options?: { | ||
initialValue?: R; | ||
initialIsLoading?: boolean; | ||
onError?: (error: DefaultError) => void; | ||
}) => { | ||
value: R | undefined; | ||
@@ -651,0 +658,0 @@ error: DefaultError | undefined; |
@@ -167,4 +167,4 @@ import { ClientOptions } from 'openai'; | ||
} & Omit<CreateChatCompletionBody, "prompt">>; | ||
type VectorSearchResult = any[]; | ||
type VectorSearchBody = WithDb<{ | ||
type DotProductSearchResult = any[]; | ||
type DotProductSearchBody = WithDb<{ | ||
query: string; | ||
@@ -214,3 +214,3 @@ queryEmbedding?: Embedding; | ||
searchChatCompletion: (body: SearchChatCompletionBody) => Promise<SearchChatCompletionResult>; | ||
vectorSearch: <R_6 extends VectorSearchResult = VectorSearchResult>(body: VectorSearchBody) => Promise<R_6>; | ||
dotProductSearch: <R_6 extends DotProductSearchResult = DotProductSearchResult>(body: DotProductSearchBody) => Promise<R_6>; | ||
}; | ||
@@ -258,5 +258,5 @@ | ||
searchChatCompletion: (body: SearchChatCompletionBody) => Promise<SearchChatCompletionResult>; | ||
vectorSearch: <R_6 extends VectorSearchResult = VectorSearchResult>(body: VectorSearchBody) => Promise<R_6>; | ||
dotProductSearch: <R_6 extends DotProductSearchResult = DotProductSearchResult>(body: DotProductSearchBody) => Promise<R_6>; | ||
}; | ||
handleRoute: <K_1 extends "query" | "createEmbedding" | "insertOne" | "insertMany" | "updateMany" | "deleteMany" | "findOne" | "findMany" | "createFileEmbeddings" | "createAndInsertFileEmbeddings" | "createChatCompletion" | "searchChatCompletion" | "vectorSearch">(route: K_1, ...args: Parameters<{ | ||
handleRoute: <K_1 extends "query" | "createEmbedding" | "insertOne" | "insertMany" | "updateMany" | "deleteMany" | "findOne" | "findMany" | "createFileEmbeddings" | "createAndInsertFileEmbeddings" | "createChatCompletion" | "searchChatCompletion" | "dotProductSearch">(route: K_1, ...args: Parameters<{ | ||
insertOne: <R extends unknown = any>(body: InsertOneBody<R>[Connection<T>["type"]]) => Promise<R>; | ||
@@ -274,3 +274,3 @@ insertMany: <R_1 extends any[] = any[]>(body: InsertManyBody<R_1>[Connection<T>["type"]]) => Promise<R_1>; | ||
searchChatCompletion: (body: SearchChatCompletionBody) => Promise<SearchChatCompletionResult>; | ||
vectorSearch: <R_6 extends VectorSearchResult = VectorSearchResult>(body: VectorSearchBody) => Promise<R_6>; | ||
dotProductSearch: <R_6 extends DotProductSearchResult = DotProductSearchResult>(body: DotProductSearchBody) => Promise<R_6>; | ||
}[K_1]>) => ReturnType<{ | ||
@@ -289,3 +289,3 @@ insertOne: <R extends unknown = any>(body: InsertOneBody<R>[Connection<T>["type"]]) => Promise<R>; | ||
searchChatCompletion: (body: SearchChatCompletionBody) => Promise<SearchChatCompletionResult>; | ||
vectorSearch: <R_6 extends VectorSearchResult = VectorSearchResult>(body: VectorSearchBody) => Promise<R_6>; | ||
dotProductSearch: <R_6 extends DotProductSearchResult = DotProductSearchResult>(body: DotProductSearchBody) => Promise<R_6>; | ||
}[K_1]>; | ||
@@ -292,0 +292,0 @@ }; |
@@ -408,4 +408,4 @@ 'use strict'; | ||
// src/server/controllers/vectorSearch.ts | ||
var vectorSearchController = (connection, ai) => { | ||
// src/server/controllers/dotProductSearch.ts | ||
var dotProductSearchController = (connection, ai) => { | ||
return (body) => __async(void 0, null, function* () { | ||
@@ -428,3 +428,7 @@ try { | ||
const query2 = [ | ||
{ $addFields: { similarity: { $dotProduct: [`$${embeddingField}`, queryBuffer] } } } | ||
{ | ||
$addFields: { | ||
similarity: { $dotProduct: [`$${embeddingField}`, queryBuffer] } | ||
} | ||
} | ||
]; | ||
@@ -539,6 +543,9 @@ if (!includeEmbedding) { | ||
createFileEmbeddings: createFileEmbeddingsController(ai), | ||
createAndInsertFileEmbeddings: createAndInsertFileEmbeddingsController(connection, ai), | ||
createAndInsertFileEmbeddings: createAndInsertFileEmbeddingsController( | ||
connection, | ||
ai | ||
), | ||
createChatCompletion: createChatCompletionController(ai), | ||
searchChatCompletion: searchChatCompletionController(connection, ai), | ||
vectorSearch: vectorSearchController(connection, ai) | ||
dotProductSearch: dotProductSearchController(connection, ai) | ||
}; | ||
@@ -545,0 +552,0 @@ } |
@@ -169,4 +169,4 @@ import { ClientOptions } from 'openai'; | ||
} & Omit<CreateChatCompletionBody, "prompt">>; | ||
type VectorSearchResult = any[]; | ||
type VectorSearchBody = WithDb<{ | ||
type DotProductSearchResult = any[]; | ||
type DotProductSearchBody = WithDb<{ | ||
query: string; | ||
@@ -204,2 +204,2 @@ queryEmbedding?: Embedding; | ||
export { AIConfig, AICustomizers, AggregateQuery, ChatCompletion, ChatCompletionMessage, Connection, ConnectionConfigsMap, ConnectionTypes, CreateAndInsertFileEmbeddingsBody, CreateAndInsertFileEmbeddingsRequestBody, CreateAndInsertFileEmbeddingsResult, CreateChatCompletion, CreateChatCompletionArgs, CreateChatCompletionBody, CreateChatCompletionParams, CreateChatCompletionResult, CreateEmbedding, CreateEmbeddingArgs, CreateEmbeddingBody, CreateEmbeddingResult, CreateFileEmbeddingsBody, CreateFileEmbeddingsRequestBody, CreateFileEmbeddingsResult, DefaultError, DeleteManyBody, DeleteManyResult, Embedding, EmbeddingInput, FindManyBody, FindManyResult, FindOneBody, FindOneResult, InsertManyBody, InsertManyResult, InsertOneBody, InsertOneResult, KaiConnection, KaiConnectionConfig, MySQLConnection, MySQLConnectionConfig, MySQLSet, MySQLWhere, QueryBody, QueryResult, Request, RequestInit, SearchChatCompletionBody, SearchChatCompletionResult, UpdateManyBody, UpdateManyResult, VectorSearchBody, VectorSearchResult }; | ||
export { AIConfig, AICustomizers, AggregateQuery, ChatCompletion, ChatCompletionMessage, Connection, ConnectionConfigsMap, ConnectionTypes, CreateAndInsertFileEmbeddingsBody, CreateAndInsertFileEmbeddingsRequestBody, CreateAndInsertFileEmbeddingsResult, CreateChatCompletion, CreateChatCompletionArgs, CreateChatCompletionBody, CreateChatCompletionParams, CreateChatCompletionResult, CreateEmbedding, CreateEmbeddingArgs, CreateEmbeddingBody, CreateEmbeddingResult, CreateFileEmbeddingsBody, CreateFileEmbeddingsRequestBody, CreateFileEmbeddingsResult, DefaultError, DeleteManyBody, DeleteManyResult, DotProductSearchBody, DotProductSearchResult, Embedding, EmbeddingInput, FindManyBody, FindManyResult, FindOneBody, FindOneResult, InsertManyBody, InsertManyResult, InsertOneBody, InsertOneResult, KaiConnection, KaiConnectionConfig, MySQLConnection, MySQLConnectionConfig, MySQLSet, MySQLWhere, QueryBody, QueryResult, Request, RequestInit, SearchChatCompletionBody, SearchChatCompletionResult, UpdateManyBody, UpdateManyResult }; |
Sorry, the diff of this file is not supported yet
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
122419
2760
665