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: add support for custom headers #4040

Merged
merged 4 commits into from
Feb 9, 2023
Merged
Changes from 3 commits
Commits
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
11 changes: 9 additions & 2 deletions haystack/document_stores/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(
timeout_config: tuple = (5, 15),
username: Optional[str] = None,
password: Optional[str] = None,
additional_headers: Optional[Dict[str, Any]] = None,
index: str = "Document",
embedding_dim: int = 768,
content_field: str = "content",
Expand All @@ -85,6 +86,7 @@ def __init__(
:param timeout_config: Weaviate Timeout config as a tuple of (retries, time out seconds).
:param username: username (standard authentication via http_auth)
:param password: password (standard authentication via http_auth)
:param additional_headers: additional headers to be included in the requests sent to Weaviate e.g. bearer token
:param index: Index name for document text, embedding and metadata (in Weaviate terminology, this is a "Class" in Weaviate schema).
:param embedding_dim: The embedding vector size. Default: 768.
:param content_field: Name of field that might contain the answer and will therefore be passed to the Reader Model (e.g. "full_text").
Expand Down Expand Up @@ -121,10 +123,15 @@ def __init__(
if username and password:
secret = AuthClientPassword(username, password)
self.weaviate_client = client.Client(
url=weaviate_url, auth_client_secret=secret, timeout_config=timeout_config
url=weaviate_url,
auth_client_secret=secret,
timeout_config=timeout_config,
additional_headers=additional_headers,
)
else:
self.weaviate_client = client.Client(url=weaviate_url, timeout_config=timeout_config)
self.weaviate_client = client.Client(
url=weaviate_url, timeout_config=timeout_config, additional_headers=additional_headers
)

# Test Weaviate connection
try:
Expand Down