Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje authored Aug 16, 2024
2 parents 8f229cc + 7885aa1 commit 5e9563e
Show file tree
Hide file tree
Showing 64 changed files with 149 additions and 67 deletions.
8 changes: 5 additions & 3 deletions integrations/chroma/example/example.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Colab: https://colab.research.google.com/drive/1YpDetI8BRbObPDEVdfqUcwhEX9UUXP-m?usp=sharing

import os
from pathlib import Path

from haystack import Pipeline
from haystack.components.converters import TextFileToDocument
from haystack.components.writers import DocumentWriter

from haystack_integrations.document_stores.chroma import ChromaDocumentStore
from haystack_integrations.components.retrievers.chroma import ChromaQueryTextRetriever
from haystack_integrations.document_stores.chroma import ChromaDocumentStore

# Chroma is used in-memory so we use the same instances in the two pipelines below
document_store = ChromaDocumentStore()

HERE = Path(__file__).resolve().parent
file_paths = [HERE / "data" / Path(name) for name in os.listdir("data")]

# Chroma is used in-memory so we use the same instances in the two pipelines below
document_store = ChromaDocumentStore()

indexing = Pipeline()
indexing.add_component("converter", TextFileToDocument())
Expand Down
13 changes: 7 additions & 6 deletions integrations/chroma/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ dependencies = [
]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = ["ruff check {args:. --exclude tests/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
all = ["style", "typing"]

[tool.hatch.metadata]
Expand All @@ -85,7 +85,7 @@ skip-string-normalization = true
[tool.ruff]
target-version = "py38"
line-length = 120
select = [
lint.select = [
"A",
"ARG",
"B",
Expand All @@ -112,7 +112,7 @@ select = [
"W",
"YTT",
]
ignore = [
lint.ignore = [
# Allow non-abstract empty methods in abstract base classes
"B027",
# Allow boolean positional values in function calls, like `dict.get(... True)`
Expand All @@ -130,21 +130,22 @@ ignore = [
# Ignore unused params
"ARG002",
]
unfixable = [
lint.unfixable = [
# Don't touch unused imports
"F401",
]
exclude = ["example"]

[tool.ruff.isort]
known-first-party = ["src"]
known-first-party = ["src", "example", "tests"]

[tool.ruff.flake8-tidy-imports]
ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]
"example/**/*" = ["T201"]

[tool.coverage.run]
source = ["haystack_integrations"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from haystack import Document, component, default_from_dict, default_to_dict
from haystack.document_stores.types import FilterPolicy
from haystack.document_stores.types.filter_policy import apply_filter_policy

from haystack_integrations.document_stores.chroma import ChromaDocumentStore


Expand Down
1 change: 1 addition & 0 deletions integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DeleteDocumentsTest,
LegacyFilterDocumentsTest,
)

from haystack_integrations.document_stores.chroma import ChromaDocumentStore


Expand Down
1 change: 1 addition & 0 deletions integrations/chroma/tests/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
import pytest
from haystack.document_stores.types import FilterPolicy

from haystack_integrations.components.retrievers.chroma import ChromaQueryTextRetriever
from haystack_integrations.document_stores.chroma import ChromaDocumentStore

Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/examples/cohere_embedding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from haystack import Document, Pipeline
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
from haystack.document_stores.in_memory import InMemoryDocumentStore

from haystack_integrations.components.embedders.cohere.document_embedder import CohereDocumentEmbedder
from haystack_integrations.components.embedders.cohere.text_embedder import CohereTextEmbedder

Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/examples/cohere_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from haystack.components.joiners import BranchJoiner
from haystack.components.validators import JsonSchemaValidator
from haystack.dataclasses import ChatMessage

from haystack_integrations.components.generators.cohere import CohereChatGenerator

# Defines a JSON schema for validating a person's data. The schema specifies that a valid object must
Expand Down
1 change: 1 addition & 0 deletions integrations/cohere/examples/cohere_ranker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from haystack import Document, Pipeline
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever
from haystack.document_stores.in_memory import InMemoryDocumentStore

from haystack_integrations.components.rankers.cohere import CohereRanker

# Note set your API key by running the below command in your terminal
Expand Down
14 changes: 11 additions & 3 deletions integrations/cohere/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/cohere-v[0-9]*"'

[tool.hatch.envs.default]
dependencies = ["coverage[toml]>=6.5", "pytest", "pytest-rerunfailures", "haystack-pydoc-tools"]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"pytest-rerunfailures",
"haystack-pydoc-tools",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
Expand All @@ -59,8 +64,11 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = [
"ruff check {args:. --exclude tests/}",
"black --check --diff {args:.}",
]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
all = ["style", "typing"]

[tool.black]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from haystack import Document, component, default_from_dict, default_to_dict
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack_integrations.components.embedders.cohere.utils import get_async_response, get_response

from cohere import AsyncClient, Client
from haystack_integrations.components.embedders.cohere.utils import get_async_response, get_response


@component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from haystack import component, default_from_dict, default_to_dict
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack_integrations.components.embedders.cohere.utils import get_async_response, get_response

from cohere import AsyncClient, Client
from haystack_integrations.components.embedders.cohere.utils import get_async_response, get_response


@component
Expand Down
1 change: 1 addition & 0 deletions integrations/fastembed/examples/example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from haystack import Document, Pipeline
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
from haystack.document_stores.in_memory import InMemoryDocumentStore

from haystack_integrations.components.embedders.fastembed import FastembedDocumentEmbedder, FastembedTextEmbedder

document_store = InMemoryDocumentStore(embedding_similarity_function="cosine")
Expand Down
1 change: 1 addition & 0 deletions integrations/fastembed/examples/sparse_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# involving indexing and retrieval of documents.

from haystack import Document

from haystack_integrations.components.embedders.fastembed import FastembedSparseDocumentEmbedder

document_list = [
Expand Down
4 changes: 2 additions & 2 deletions integrations/fastembed/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243", "numpy"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = ["ruff check {args:. --exclude tests/, examples/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/, examples/}", "style"]
all = ["style", "typing"]

[tool.black]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import pytest
from haystack import Document, default_from_dict

from haystack_integrations.components.embedders.fastembed.fastembed_document_embedder import (
FastembedDocumentEmbedder,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from haystack import Document, default_from_dict
from haystack.dataclasses.sparse_embedding import SparseEmbedding

from haystack_integrations.components.embedders.fastembed.fastembed_sparse_document_embedder import (
FastembedSparseDocumentEmbedder,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from haystack import default_from_dict
from haystack.dataclasses.sparse_embedding import SparseEmbedding

from haystack_integrations.components.embedders.fastembed.fastembed_sparse_text_embedder import (
FastembedSparseTextEmbedder,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import pytest
from haystack import default_from_dict

from haystack_integrations.components.embedders.fastembed.fastembed_text_embedder import (
FastembedTextEmbedder,
)
Expand Down
4 changes: 2 additions & 2 deletions integrations/jina/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = ["ruff check {args:. --exclude tests/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
all = ["style", "typing"]

[tool.black]
Expand Down
1 change: 1 addition & 0 deletions integrations/jina/tests/test_document_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests
from haystack import Document
from haystack.utils import Secret

from haystack_integrations.components.embedders.jina import JinaDocumentEmbedder


Expand Down
1 change: 1 addition & 0 deletions integrations/jina/tests/test_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests
from haystack import Document
from haystack.utils import Secret

from haystack_integrations.components.rankers.jina import JinaRanker


Expand Down
1 change: 1 addition & 0 deletions integrations/jina/tests/test_text_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import requests
from haystack.utils import Secret

from haystack_integrations.components.embedders.jina import JinaTextEmbedder


Expand Down
4 changes: 2 additions & 2 deletions integrations/langfuse/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]

[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = ["ruff check {args:. --exclude tests/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
all = ["style", "typing"]

[tool.hatch.metadata]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from haystack import component, tracing
from haystack_integrations.tracing.langfuse import LangfuseTracer

from haystack_integrations.tracing.langfuse import LangfuseTracer
from langfuse import Langfuse


Expand Down
1 change: 1 addition & 0 deletions integrations/mistral/examples/indexing_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from haystack.components.preprocessors import DocumentSplitter
from haystack.components.writers import DocumentWriter
from haystack.document_stores.in_memory import InMemoryDocumentStore

from haystack_integrations.components.embedders.mistral.document_embedder import MistralDocumentEmbedder

document_store = InMemoryDocumentStore()
Expand Down
1 change: 1 addition & 0 deletions integrations/mistral/examples/streaming_chat_with_rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from haystack.components.writers import DocumentWriter
from haystack.dataclasses import ChatMessage
from haystack.document_stores.in_memory import InMemoryDocumentStore

from haystack_integrations.components.embedders.mistral.document_embedder import MistralDocumentEmbedder
from haystack_integrations.components.embedders.mistral.text_embedder import MistralTextEmbedder
from haystack_integrations.components.generators.mistral import MistralChatGenerator
Expand Down
14 changes: 11 additions & 3 deletions integrations/mistral/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ root = "../.."
git_describe_command = 'git describe --tags --match="integrations/mistral-v[0-9]*"'

[tool.hatch.envs.default]
dependencies = ["coverage[toml]>=6.5", "pytest", "pytest-rerunfailures", "haystack-pydoc-tools"]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
"pytest-rerunfailures",
"haystack-pydoc-tools",
]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
Expand All @@ -59,8 +64,11 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = [
"ruff check {args:. --exclude tests/}",
"black --check --diff {args:.}",
]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
all = ["style", "typing"]

[tool.black]
Expand Down
1 change: 1 addition & 0 deletions integrations/mongodb_atlas/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from haystack.components.embedders import SentenceTransformersDocumentEmbedder, SentenceTransformersTextEmbedder
from haystack.components.preprocessors import DocumentSplitter
from haystack.components.writers import DocumentWriter

from haystack_integrations.components.retrievers.mongodb_atlas import MongoDBAtlasEmbeddingRetriever
from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore

Expand Down
4 changes: 2 additions & 2 deletions integrations/mongodb_atlas/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = ["ruff check {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
style = ["ruff check {args:. --exclude tests/, examples/}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/, examples/}", "style"]
all = ["style", "typing"]

[tool.black]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from haystack.dataclasses import Document
from haystack.document_stores.types import FilterPolicy
from haystack.document_stores.types.filter_policy import apply_filter_policy

from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError
from haystack.document_stores.types import DuplicatePolicy
from haystack.utils import Secret, deserialize_secrets_inplace
from haystack_integrations.document_stores.mongodb_atlas.filters import _normalize_filters
from pymongo import InsertOne, MongoClient, ReplaceOne, UpdateOne
from pymongo.collection import Collection
from pymongo.driver_info import DriverInfo
from pymongo.errors import BulkWriteError

from haystack_integrations.document_stores.mongodb_atlas.filters import _normalize_filters

logger = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion integrations/mongodb_atlas/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
from haystack.document_stores.types import DuplicatePolicy
from haystack.testing.document_store import DocumentStoreBaseTests
from haystack.utils import Secret
from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore
from pandas import DataFrame
from pymongo import MongoClient
from pymongo.driver_info import DriverInfo

from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore


@patch("haystack_integrations.document_stores.mongodb_atlas.document_store.MongoClient")
def test_init_is_lazy(_mock_client):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
from haystack.document_stores.errors import DocumentStoreError

from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore


Expand Down
Loading

0 comments on commit 5e9563e

Please sign in to comment.