Skip to content

Commit d494329

Browse files
ArmekDisiok
andauthored
Make pgvector's setup (extension, schema, and table creation) optional (run-llama#8656)
* Make pgvector setup optional * wip --------- Co-authored-by: Simon Suo <[email protected]>
1 parent 357abbf commit d494329

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## Unreleased
4+
5+
### New Features
6+
7+
- Make pgvector's setup (extension, schema, and table creation) optional (#8656)
8+
39
## [0.8.59] - 2023-11-02
410

511
- Deepmemory support (#8625)

llama_index/vector_stores/postgres.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class PGVectorStore(BasePydanticVectorStore):
109109
hybrid_search: bool
110110
text_search_config: str
111111
cache_ok: bool
112+
perform_setup: bool
112113
debug: bool
113114

114115
_base: Any = PrivateAttr()
@@ -129,6 +130,7 @@ def __init__(
129130
text_search_config: str = "english",
130131
embed_dim: int = 1536,
131132
cache_ok: bool = False,
133+
perform_setup: bool = True,
132134
debug: bool = False,
133135
) -> None:
134136
try:
@@ -175,6 +177,7 @@ def __init__(
175177
text_search_config=text_search_config,
176178
embed_dim=embed_dim,
177179
cache_ok=cache_ok,
180+
perform_setup=perform_setup,
178181
debug=debug,
179182
)
180183

@@ -207,6 +210,7 @@ def from_params(
207210
text_search_config: str = "english",
208211
embed_dim: int = 1536,
209212
cache_ok: bool = False,
213+
perform_setup: bool = True,
210214
debug: bool = False,
211215
) -> "PGVectorStore":
212216
"""Return connection string from database parameters."""
@@ -226,6 +230,7 @@ def from_params(
226230
text_search_config=text_search_config,
227231
embed_dim=embed_dim,
228232
cache_ok=cache_ok,
233+
perform_setup=perform_setup,
229234
debug=debug,
230235
)
231236

@@ -269,9 +274,10 @@ def _create_extension(self) -> None:
269274
def _initialize(self) -> None:
270275
if not self._is_initialized:
271276
self._connect()
272-
self._create_extension()
273-
self._create_schema_if_not_exists()
274-
self._create_tables_if_not_exists()
277+
if self.perform_setup:
278+
self._create_extension()
279+
self._create_schema_if_not_exists()
280+
self._create_tables_if_not_exists()
275281
self._is_initialized = True
276282

277283
def _node_to_table_row(self, node: BaseNode) -> Any:

0 commit comments

Comments
 (0)