Skip to content

Commit

Permalink
mount Ollama in haystack_integrations (#216)
Browse files Browse the repository at this point in the history
* mount ollama in haystack_integrations

* fix fmt
  • Loading branch information
anakin87 authored Jan 16, 2024
1 parent 020f273 commit 2c39561
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 21 deletions.
3 changes: 1 addition & 2 deletions integrations/ollama/example/chat_generator_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# docker exec ollama ollama pull orca-mini

from haystack.dataclasses import ChatMessage

from ollama_haystack import OllamaChatGenerator
from haystack_integrations.components.generators.ollama import OllamaChatGenerator

messages = [
ChatMessage.from_user("What's Natural Language Processing?"),
Expand Down
3 changes: 1 addition & 2 deletions integrations/ollama/example/generator_example.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.in_memory import InMemoryDocumentStore

from ollama_haystack import OllamaGenerator
from haystack_integrations.components.generators.ollama import OllamaGenerator

document_store = InMemoryDocumentStore()
document_store.write_documents(
Expand Down
14 changes: 9 additions & 5 deletions integrations/ollama/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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/ollama"

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

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

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

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

[tool.black]
target-version = ["py37"]
Expand Down Expand Up @@ -140,7 +143,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 @@ -150,13 +153,13 @@ ban-relative-imports = "all"


[tool.coverage.run]
source_pkgs = ["ollama_haystack", "tests"]
source_pkgs = ["src", "tests"]
branch = true
parallel = true


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

[tool.coverage.report]
Expand All @@ -177,6 +180,7 @@ addopts = [
[[tool.mypy.overrides]]
module = [
"haystack.*",
"haystack_integrations.*",
"pytest.*"
]
ignore_missing_imports = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .chat.chat_generator import OllamaChatGenerator
from .generator import OllamaGenerator

__all__ = ["OllamaGenerator", "OllamaChatGenerator"]
8 changes: 0 additions & 8 deletions integrations/ollama/src/ollama_haystack/__init__.py

This file was deleted.

3 changes: 1 addition & 2 deletions integrations/ollama/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

import pytest
from haystack.dataclasses import ChatMessage, ChatRole
from haystack_integrations.components.generators.ollama import OllamaChatGenerator
from requests import HTTPError, Response

from ollama_haystack import OllamaChatGenerator


@pytest.fixture
def chat_messages() -> List[ChatMessage]:
Expand Down
3 changes: 1 addition & 2 deletions integrations/ollama/tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
# SPDX-License-Identifier: Apache-2.0

import pytest
from haystack_integrations.components.generators.ollama import OllamaGenerator
from requests import HTTPError

from ollama_haystack import OllamaGenerator


class TestOllamaGenerator:
@pytest.mark.integration
Expand Down

0 comments on commit 2c39561

Please sign in to comment.