@@ -9,7 +9,7 @@ import { getEnvironmentVariable } from "@langchain/core/utils/env";
99import { maximalMarginalRelevance } from "@langchain/core/utils/math" ;
1010
1111/**
12- * Metadata type that supports various filtering operations.
12+ * Strict metadata filter type that supports various filtering operations.
1313 *
1414 * For simple equality filters, use:
1515 * ```typescript
@@ -41,7 +41,7 @@ import { maximalMarginalRelevance } from "@langchain/core/utils/math";
4141 * }
4242 * ```
4343 */
44- type MetadataFilter = Record <
44+ type StrictMetadataFilter = Record <
4545 string ,
4646 | string
4747 | number
@@ -66,6 +66,17 @@ type MetadataFilter = Record<
6666 }
6767> ;
6868
69+ /**
70+ * @deprecated Use StrictMetadataFilter for better type safety. This type will be removed.
71+ * Legacy metadata filter type for backward compatibility
72+ */
73+ type LegacyMetadataFilter = Record < string , unknown > ;
74+
75+ /**
76+ * Metadata filter type that supports both strict typing and legacy usage
77+ */
78+ type MetadataFilter = StrictMetadataFilter | LegacyMetadataFilter ;
79+
6980type Metadata = Record < string , unknown > ;
7081
7182export type DistanceStrategy = "cosine" | "innerProduct" | "euclidean" ;
@@ -645,7 +656,7 @@ export class PGVectorStore extends VectorStore {
645656
646657 for ( const [ key , value ] of Object . entries ( filter ) ) {
647658 if ( typeof value === "object" && value !== null ) {
648- const _value : Record < string , unknown > = value ;
659+ const _value = value as Record < string , unknown > ;
649660 const currentParamCount = paramCount ;
650661
651662 if ( Array . isArray ( _value . in ) ) {
0 commit comments