langchain icon indicating copy to clipboard operation
langchain copied to clipboard

ClickHouse ERROR: Distance function argument of Annoy index must be of type String.

Open sheiy opened this issue 1 year ago • 2 comments

System Info

langchain: 0.0.200 platform: macOS python: 3.10.11 clickhouse: version 23.5.2.7 (official build)

Who can help?

@hwchase17

Information

  • [ ] The official example notebooks/scripts
  • [X] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [X] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [ ] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

image

Expected behavior

success write data to clickhouse

sheiy avatar Jun 15 '23 07:06 sheiy

Generated by a 🤖

Anwser

To resolve the issue, update the index_param in ClickHouseSettings to use the metric parameter as a string:

index_param: Optional[Union[List, Dict]] = [100, f"'{metric}'"]

Also, ensure the metric parameter in the Annoy.from_texts() function is set to a string value, such as "angular" or "euclidean":

vector_store_v2 = Annoy.from_texts(
    texts, embeddings_func, metric="angular", n_trees=100, n_jobs=1
)

Sources


This response is meant to be helpful and save users time. It is not meant to be a precise solution.

Please leave a 👍 if this is helpful and 👎 if it is irrelevant

devstein avatar Jun 16 '23 01:06 devstein

@haoch do you have any idea?

sheiy avatar Jun 16 '23 03:06 sheiy

@sheiy Will test with the clickhouse version you used and get back to you shortly.

haoch avatar Jun 18 '23 00:06 haoch

@sheiy It will be fixed with #6385

haoch avatar Jun 18 '23 23:06 haoch