Skip to content

Commit

Permalink
declare FilterType
Browse files Browse the repository at this point in the history
  • Loading branch information
cinqisap committed Nov 22, 2024
1 parent 274dffa commit bdbbddc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libs/langchain-community/src/vectorstores/hanavector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export class HanaDB extends VectorStore {

private vectorColumnLength: number;

declare FilterType: Filter;

private specificMetadataColumns: string[];

_vectorstoreType(): string {
Expand Down Expand Up @@ -390,7 +392,7 @@ export class HanaDB extends VectorStore {
* @returns A tuple containing the WHERE clause string and an array of query parameters.
*/
private createWhereByFilter(
filter?: Filter
filter?: this["FilterType"]
): [string, Array<ComparisonRValue>] {
let whereStr = "";
let queryTuple: Array<ComparisonRValue> = [];
Expand All @@ -410,7 +412,7 @@ export class HanaDB extends VectorStore {
* @returns A tuple containing the WHERE clause string and an array of query parameters.
*/
private processFilterObject(
filter: Filter
filter: this["FilterType"]
): [string, Array<ComparisonRValue>] {
let whereStr = "";
const queryTuple: Array<ComparisonRValue> = [];
Expand Down Expand Up @@ -773,7 +775,7 @@ export class HanaDB extends VectorStore {
async similaritySearch(
query: string,
k: number,
filter?: Filter
filter?: this["FilterType"]
): Promise<Document[]> {
const results = await this.similaritySearchWithScore(query, k, filter);
return results.map((result) => result[0]);
Expand All @@ -790,7 +792,7 @@ export class HanaDB extends VectorStore {
async similaritySearchWithScore(
query: string,
k: number,
filter?: Filter
filter?: this["FilterType"]
): Promise<[Document, number][]> {
const queryEmbedding = await this.embeddings.embedQuery(query);
return this.similaritySearchVectorWithScore(queryEmbedding, k, filter);
Expand All @@ -807,7 +809,7 @@ export class HanaDB extends VectorStore {
async similaritySearchVectorWithScore(
queryEmbedding: number[],
k: number,
filter?: Filter
filter?: this["FilterType"]
): Promise<[Document, number][]> {
const wholeResult = await this.similaritySearchWithScoreAndVectorByVector(
queryEmbedding,
Expand All @@ -828,7 +830,7 @@ export class HanaDB extends VectorStore {
async similaritySearchWithScoreAndVectorByVector(
embedding: number[],
k: number,
filter?: Filter
filter?: this["FilterType"]
): Promise<Array<[Document, number, number[]]>> {
// Sanitize inputs
const sanitizedK = HanaDB.sanitizeInt(k);
Expand Down

0 comments on commit bdbbddc

Please sign in to comment.