Skip to content

Commit

Permalink
Merge pull request #25 from epsilla-cloud/facets-support
Browse files Browse the repository at this point in the history
facets support;
  • Loading branch information
richard-epsilla authored Apr 19, 2024
2 parents d216c0e + c23295a commit ecd0c57
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epsillajs",
"version": "0.3.5",
"version": "0.3.6",
"description": "A JS library to connect Epsilla vector database",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Index {
name: string;
field: string;
model?: string;
dimensions?: number;
}

export interface SparseVector {
Expand All @@ -41,6 +42,12 @@ export interface QueryPayload {
response?: string[];
filter?: string;
withDistance?: boolean;
facets?: FacetConfig[];
}

export interface FacetConfig {
group?: string[];
aggregate: string[];
}

export interface QueryConfig {
Expand All @@ -52,6 +59,7 @@ export interface QueryConfig {
response?: string[];
filter?: string;
withDistance?: boolean;
facets?: FacetConfig[];
}

export interface DeleteRecordsConfig {
Expand All @@ -65,6 +73,7 @@ export interface PreviewConfig {
filter?: string;
skip?: number;
limit?: number;
facets?: FacetConfig[];
}

export interface EpsillaBaseResponse {
Expand Down
14 changes: 7 additions & 7 deletions src/searchengine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// VectorRetriever.ts
import { VectorDB } from './cloud';
import {
QueryPayload,
SearchEngineCandidate,
Reranker,
RetrieverConfig,
RerankerConfig,
RetrieverConfig,
SearchEngineCandidate
} from './models';
import EpsillaDB from './vectordb';
import { VectorDB } from './cloud';

export class VectorRetriever {
private dbClient: EpsillaDB | VectorDB;
Expand All @@ -29,7 +29,7 @@ export class VectorRetriever {
queryVector?: any,
response?: string[],
limit: number = 2,
filter: string = '',
filter: string = ''
) {
this.dbClient = dbClient;
this.table = table;
Expand All @@ -52,7 +52,7 @@ export class VectorRetriever {
response: this.response,
limit: this.limit,
filter: this.filter,
withDistance: true,
withDistance: true
};
const response = await this.dbClient.query(this.table, queryPayload);
if (response instanceof Error) {
Expand Down Expand Up @@ -155,7 +155,7 @@ export class RelativeScoreFusionReranker implements Reranker {
if (aggregatedScores[id]) {
aggregatedScores[id].score += normalizedScore as number;
} else {
aggregatedScores[id] = {
aggregatedScores[id] = {
candidate: list.find(candidate => candidate['@id'] === id) as SearchEngineCandidate,
score: normalizedScore as number
};
Expand Down Expand Up @@ -202,7 +202,7 @@ export class DistributionBasedScoreFusionReranker implements Reranker {
throw new Error("The length of scaleRanges should be equal to the number of candidates lists.");
}

const normalizedLists = candidatesLists.map((list, index) =>
const normalizedLists = candidatesLists.map((list, index) =>
this.normalizeDistances(this.scaleRanges[index], list)
);

Expand Down

0 comments on commit ecd0c57

Please sign in to comment.