cmem-plugin-pgvector 0.6.3__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cmem-plugin-pgvector
3
- Version: 0.6.3
3
+ Version: 0.7.0
4
4
  Summary: Store and search for embedding vectors in a Postgres vector store.
5
5
  License: Apache-2.0
6
6
  Keywords: eccenca Corporate Memory,plugin
@@ -13,10 +13,11 @@ from cmem_plugin_base.dataintegration.ports import (
13
13
  FixedNumberOfInputs,
14
14
  FixedSchemaPort,
15
15
  )
16
- from cmem_plugin_base.dataintegration.types import IntParameterType
16
+ from cmem_plugin_base.dataintegration.types import EnumParameterType, IntParameterType
17
17
  from langchain_core.documents import Document
18
18
  from langchain_core.embeddings import Embeddings
19
19
  from langchain_postgres import PGVector
20
+ from langchain_postgres.vectorstores import DistanceStrategy
20
21
 
21
22
  from cmem_plugin_pgvector.commons import DatabaseParams
22
23
 
@@ -86,6 +87,14 @@ The results in this output are structured like this:
86
87
  default_value=10,
87
88
  param_type=IntParameterType(),
88
89
  ),
90
+ PluginParameter(
91
+ name="distance_strategy",
92
+ label="Distance Strategy",
93
+ description="The distance strategy to use. (default: COSINE)",
94
+ param_type=EnumParameterType(enum_type=DistanceStrategy),
95
+ default_value=DistanceStrategy.COSINE,
96
+ advanced=True,
97
+ ),
89
98
  ],
90
99
  )
91
100
  class PGVectorSearchPlugin(WorkflowPlugin):
@@ -105,6 +114,7 @@ class PGVectorSearchPlugin(WorkflowPlugin):
105
114
  report: ExecutionReport
106
115
  search_result_path: str
107
116
  top_k: int
117
+ distance_strategy: DistanceStrategy
108
118
 
109
119
  def __init__( # noqa: PLR0913
110
120
  self,
@@ -117,6 +127,7 @@ class PGVectorSearchPlugin(WorkflowPlugin):
117
127
  search_result_path: str = "_search_result",
118
128
  embedding_query_path: str = "_embedding",
119
129
  top_k: int = 10,
130
+ distance_strategy: DistanceStrategy = DistanceStrategy.COSINE,
120
131
  ) -> None:
121
132
  self.collection_name = collection_name
122
133
  self.user = user
@@ -126,6 +137,7 @@ class PGVectorSearchPlugin(WorkflowPlugin):
126
137
  self.embedding_query_path = embedding_query_path
127
138
  self.search_result_path = search_result_path
128
139
  self.top_k = top_k
140
+ self.distance_strategy = distance_strategy
129
141
 
130
142
  str_password = self.password = password if isinstance(password, str) else password.decrypt()
131
143
  self.connection_string = (
@@ -142,6 +154,7 @@ class PGVectorSearchPlugin(WorkflowPlugin):
142
154
  embeddings=DummyEmbeddings(),
143
155
  use_jsonb=True,
144
156
  pre_delete_collection=False,
157
+ distance_strategy=distance_strategy,
145
158
  )
146
159
  self._setup_ports()
147
160
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cmem-plugin-pgvector"
3
- version = "0.6.3"
3
+ version = "0.7.0"
4
4
  license = "Apache-2.0"
5
5
  description = "Store and search for embedding vectors in a Postgres vector store."
6
6
  authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]