Skip to content

Commit

Permalink
mount llama_cpp in haystack_integrations (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 authored Jan 17, 2024
1 parent 78f9c7f commit e98a754
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from llama_cpp_haystack import LlamaCppGenerator
from haystack_integrations.components.generators.llama_cpp import LlamaCppGenerator

generator = LlamaCppGenerator(model_path="openchat-3.5-1210.Q3_K_S.gguf", n_ctx=512, n_batch=128)
generator.warm_up()
Expand Down
3 changes: 1 addition & 2 deletions integrations/llama_cpp/examples/rag_pipeline_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from haystack.components.retrievers import InMemoryEmbeddingRetriever
from haystack.components.writers import DocumentWriter
from haystack.document_stores import InMemoryDocumentStore

from llama_cpp_haystack import LlamaCppGenerator
from haystack_integrations.components.generators.llama_cpp import LlamaCppGenerator

# Load first 100 rows of the Simple Wikipedia Dataset from HuggingFace
dataset = load_dataset("pszemraj/simple_wikipedia", split="validation[:100]")
Expand Down
12 changes: 8 additions & 4 deletions integrations/llama_cpp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/m
Issues = "https://github.com/deepset-ai/haystack-core-integrations/issues"
Source = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/llama_cpp"

[tool.hatch.build.targets.wheel]
packages = ["src/haystack_integrations"]

[tool.hatch.version]
source = "vcs"
tag-pattern = 'integrations\/llama_cpp-v(?P<version>.*)'
Expand Down Expand Up @@ -73,7 +76,7 @@ dependencies = [
]

[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/llama_cpp_haystack tests}"
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
Expand All @@ -92,7 +95,7 @@ all = [
allow-direct-references = true

[tool.ruff.isort]
known-first-party = ["llama_cpp_haystack"]
known-first-party = ["src"]

[tool.black]
target-version = ["py37"]
Expand Down Expand Up @@ -142,7 +145,7 @@ unfixable = [
]

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

[tool.ruff.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
Expand All @@ -158,7 +161,7 @@ parallel = true


[tool.coverage.paths]
ollama_haystack = ["src/llama_cpp_haystack", "*/llama-cpp-haystack/src/llama_cpp_haystack"]
llama_cpp_haystack = ["src/haystack_integrations", "*/llama-cpp-haystack/src"]
tests = ["tests", "*/llama-cpp-haystack/tests"]

[tool.coverage.report]
Expand All @@ -179,6 +182,7 @@ addopts = [
[[tool.mypy.overrides]]
module = [
"haystack.*",
"haystack_integrations.*",
"pytest.*",
"llama_cpp.*"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

from llama_cpp_haystack.generator import LlamaCppGenerator
from .generator import LlamaCppGenerator

__all__ = ["LlamaCppGenerator"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Dict, List, Optional

from haystack import component

from llama_cpp import Llama

logger = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions integrations/llama_cpp/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from haystack.components.builders.prompt_builder import PromptBuilder
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.document_stores import InMemoryDocumentStore

from llama_cpp_haystack import LlamaCppGenerator
from haystack_integrations.components.generators.llama_cpp import LlamaCppGenerator


@pytest.fixture
Expand Down

0 comments on commit e98a754

Please sign in to comment.