Skip to content

Commit

Permalink
community: make SET allow_experimental_[engine]_index configurabe i…
Browse files Browse the repository at this point in the history
…n vectorstores.clickhouse (langchain-ai#18107)

## Description & Issue
While following the official doc to use clickhouse as a vectorstore, I
found only the default `annoy` index is properly supported. But I want
to try another engine `usearch` for `annoy` is not properly supported on
ARM platforms.
Here is the settings I prefer:

``` python
settings = ClickhouseSettings(
    table="wiki_Ethereum",
    index_type="usearch",  # annoy by default
    index_param=[],
)
```
The above settings do not work for the command `set
allow_experimental_annoy_index=1` is hard-coded.
This PR will make sure the experimental feature follow the `index_type`
which is also consistent with Clickhouse's naming conventions.
  • Loading branch information
bgdsh authored and al1p-R committed Feb 27, 2024
1 parent d245c9b commit 806d172
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/community/langchain_community/vectorstores/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def __init__(
)
# Enable JSON type
self.client.command("SET allow_experimental_object_type=1")
# Enable Annoy index
self.client.command("SET allow_experimental_annoy_index=1")
# Enable index
self.client.command(f"SET allow_experimental_{self.config.index_type}_index=1")
self.client.command(self.schema)

@property
Expand Down

0 comments on commit 806d172

Please sign in to comment.