mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-09-23 03:57:13 +00:00
feat(Vector): support pgvector (#1624)
This commit is contained in:
@@ -40,6 +40,21 @@ class VectorStoreComponent:
|
||||
@inject
|
||||
def __init__(self, settings: Settings) -> None:
|
||||
match settings.vectorstore.database:
|
||||
case "pgvector":
|
||||
from llama_index.vector_stores import PGVectorStore
|
||||
|
||||
if settings.pgvector is None:
|
||||
raise ValueError(
|
||||
"PGVectorStore settings not found. Please provide settings."
|
||||
)
|
||||
|
||||
self.vector_store = typing.cast(
|
||||
VectorStore,
|
||||
PGVectorStore.from_params(
|
||||
**settings.pgvector.model_dump(exclude_none=True)
|
||||
),
|
||||
)
|
||||
|
||||
case "chroma":
|
||||
try:
|
||||
import chromadb # type: ignore
|
||||
|
@@ -101,7 +101,7 @@ class LLMSettings(BaseModel):
|
||||
|
||||
|
||||
class VectorstoreSettings(BaseModel):
|
||||
database: Literal["chroma", "qdrant"]
|
||||
database: Literal["chroma", "qdrant", "pgvector"]
|
||||
|
||||
|
||||
class LocalSettings(BaseModel):
|
||||
@@ -197,6 +197,41 @@ class UISettings(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class PGVectorSettings(BaseModel):
|
||||
host: str = Field(
|
||||
"localhost",
|
||||
description="The server hosting the Postgres database",
|
||||
)
|
||||
port: int = Field(
|
||||
5432,
|
||||
description="The port on which the Postgres database is accessible",
|
||||
)
|
||||
user: str = Field(
|
||||
"postgres",
|
||||
description="The user to use to connect to the Postgres database",
|
||||
)
|
||||
password: str = Field(
|
||||
"postgres",
|
||||
description="The password to use to connect to the Postgres database",
|
||||
)
|
||||
database: str = Field(
|
||||
"postgres",
|
||||
description="The database to use to connect to the Postgres database",
|
||||
)
|
||||
embed_dim: int = Field(
|
||||
384,
|
||||
description="The dimension of the embeddings stored in the Postgres database",
|
||||
)
|
||||
schema_name: str = Field(
|
||||
"public",
|
||||
description="The name of the schema in the Postgres database where the embeddings are stored",
|
||||
)
|
||||
table_name: str = Field(
|
||||
"embeddings",
|
||||
description="The name of the table in the Postgres database where the embeddings are stored",
|
||||
)
|
||||
|
||||
|
||||
class QdrantSettings(BaseModel):
|
||||
location: str | None = Field(
|
||||
None,
|
||||
@@ -263,6 +298,7 @@ class Settings(BaseModel):
|
||||
ollama: OllamaSettings
|
||||
vectorstore: VectorstoreSettings
|
||||
qdrant: QdrantSettings | None = None
|
||||
pgvector: PGVectorSettings | None = None
|
||||
|
||||
|
||||
"""
|
||||
|
Reference in New Issue
Block a user