|
|
|
|
|
|
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
with self._get_cursor() as cur: |
|
|
with self._get_cursor() as cur: |
|
|
if dify_config.PGVECTOR_IS_OWNER: |
|
|
|
|
|
cur.execute("CREATE EXTENSION IF NOT EXISTS vector") |
|
|
|
|
|
|
|
|
cur.execute("CREATE EXTENSION IF NOT EXISTS vector") |
|
|
cur.execute(SQL_CREATE_TABLE.format(table_name=self.table_name, dimension=dimension)) |
|
|
cur.execute(SQL_CREATE_TABLE.format(table_name=self.table_name, dimension=dimension)) |
|
|
# PG hnsw index only support 2000 dimension or less |
|
|
# PG hnsw index only support 2000 dimension or less |
|
|
# ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing |
|
|
# ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing |