feat(vectorstore): Add clickhouse support as vectore store (#1883)

* Added ClickHouse vector sotre support

* port fix

* updated lock file

* fix: mypy

* fix: mypy

---------

Co-authored-by: Valery Denisov <valerydenisov@double.cloud>
Co-authored-by: Javier Martinez <javiermartinezalvarez98@gmail.com>
This commit is contained in:
Proger666 2024-07-08 16:18:22 +02:00 committed by GitHub
parent fc13368bc7
commit 2612928839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 399 additions and 5 deletions

View file

@ -121,6 +121,33 @@ class VectorStoreComponent:
collection_name="make_this_parameterizable_per_api_call",
), # TODO
)
case "clickhouse":
try:
from clickhouse_connect import ( # type: ignore
get_client,
)
from llama_index.vector_stores.clickhouse import ( # type: ignore
ClickHouseVectorStore,
)
except ImportError as e:
raise ImportError(
"ClickHouse dependencies not found, install with `poetry install --extras vector-stores-clickhouse`"
) from e
if settings.clickhouse is None:
raise ValueError(
"ClickHouse settings not found. Please provide settings."
)
clickhouse_client = get_client(
host=settings.clickhouse.host,
port=settings.clickhouse.port,
username=settings.clickhouse.username,
password=settings.clickhouse.password,
)
self.vector_store = ClickHouseVectorStore(
clickhouse_client=clickhouse_client
)
case _:
# Should be unreachable
# The settings validator should have caught this