Skip to content

Commit b342b29

Browse files
fix: Add support for a metadata column named id in PGVectorStore (#210)
Add support for a metadata column named id in PGVectorStore Fixes an issue that prevented adding a metadata column named id to the vector store, due to a conflict with the id parameter in the insert query. Users can now successfully include a metadata column with the name id. Co-authored-by: Averi Kitsch <akitsch@google.com>
1 parent 9f97676 commit b342b29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎langchain_postgres/v2/async_vectorstore.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ async def aadd_embeddings(
296296
)
297297
insert_stmt = f'INSERT INTO "{self.schema_name}"."{self.table_name}"("{self.id_column}", "{self.content_column}", "{self.embedding_column}"{hybrid_search_column}{metadata_col_names}'
298298
values = {
299-
"id": id,
299+
"langchain_id": id,
300300
"content": content,
301301
"embedding": str([float(dimension) for dimension in embedding]),
302302
}
303-
values_stmt = "VALUES (:id, :content, :embedding"
303+
values_stmt = "VALUES (:langchain_id, :content, :embedding"
304304

305305
if not embedding and can_inline_embed:
306-
values_stmt = f"VALUES (:id, :content, {self.embedding_service.embed_query_inline(content)}" # type: ignore
306+
values_stmt = f"VALUES (:langchain_id, :content, {self.embedding_service.embed_query_inline(content)}" # type: ignore
307307

308308
if self.hybrid_search_config and self.hybrid_search_config.tsv_column:
309309
lang = (

0 commit comments

Comments
 (0)