Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Weaviate): Enforce capitalized index name #3791

Merged
merged 18 commits into from
Sep 30, 2024
Merged
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8feaa3b
feat(Weaviate): Enforce capitalized index name
edwinjosechittilappilly Sep 12, 2024
dcdf405
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 12, 2024
8035778
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 13, 2024
9a4ad06
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 18, 2024
f7f330a
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 20, 2024
ab7a210
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 20, 2024
9ef84d6
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 27, 2024
0e91131
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 27, 2024
5a699cc
updated the component
edwinjosechittilappilly Sep 27, 2024
4ea1f3f
Merge branch 'fix-weaviate-index-name' of https://github.com/langflow…
edwinjosechittilappilly Sep 27, 2024
eca1511
Update Weaviate.py
edwinjosechittilappilly Sep 27, 2024
9f18536
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 27, 2024
311df54
Lint error solved
edwinjosechittilappilly Sep 27, 2024
d550e14
Merge branch 'fix-weaviate-index-name' of https://github.com/langflow…
edwinjosechittilappilly Sep 27, 2024
6699c3f
Code corrections discarded unwanted validate functions
edwinjosechittilappilly Sep 30, 2024
b56e98c
Merge branch 'main' into fix-weaviate-index-name
edwinjosechittilappilly Sep 30, 2024
52f15a8
Update Weaviate.py
edwinjosechittilappilly Sep 30, 2024
7cf57c0
Merge branch 'main' into fix-weaviate-index-name
ogabrielluiz Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/backend/base/langflow/components/vectorstores/Weaviate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

import weaviate # type: ignore
import weaviate
from langchain_community.vectorstores import Weaviate

from langflow.base.vectorstores.model import LCVectorStoreComponent, check_cached_vector_store
Expand All @@ -19,7 +19,12 @@ class WeaviateVectorStoreComponent(LCVectorStoreComponent):
inputs = [
StrInput(name="url", display_name="Weaviate URL", value="http://localhost:8080", required=True),
SecretStrInput(name="api_key", display_name="API Key", required=False),
StrInput(name="index_name", display_name="Index Name", required=True),
StrInput(
name="index_name",
display_name="Index Name",
required=True,
info="Please use capitalized index name. Weaviate requires the index name to be capitalized.",
edwinjosechittilappilly marked this conversation as resolved.
Show resolved Hide resolved
),
StrInput(name="text_key", display_name="Text Key", value="text", advanced=True),
MultilineInput(name="search_query", display_name="Search Query"),
DataInput(
Expand All @@ -37,6 +42,13 @@ class WeaviateVectorStoreComponent(LCVectorStoreComponent):
),
BoolInput(name="search_by_text", display_name="Search By Text", advanced=True),
]
index_name: str
edwinjosechittilappilly marked this conversation as resolved.
Show resolved Hide resolved

def get_valid_index_name(self, client: weaviate.Client, index_name: str) -> str:
edwinjosechittilappilly marked this conversation as resolved.
Show resolved Hide resolved
capitalized_name = index_name.capitalize()
if index_name != capitalized_name:
raise ValueError(f"Weaviate requires the index name to be capitalized. Use: {capitalized_name}")
return capitalized_name
edwinjosechittilappilly marked this conversation as resolved.
Show resolved Hide resolved

@check_cached_vector_store
def build_vector_store(self) -> Weaviate:
Expand All @@ -46,6 +58,8 @@ def build_vector_store(self) -> Weaviate:
else:
client = weaviate.Client(url=self.url)

self.index_name = self.get_valid_index_name(client, self.index_name)
edwinjosechittilappilly marked this conversation as resolved.
Show resolved Hide resolved

documents = []
for _input in self.ingest_data or []:
if isinstance(_input, Data):
Expand Down
Loading