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

chore: use native support of namespace packas #11

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions packages/ragbits-common/examples/llm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from pydantic import BaseModel

from ragbits_common.llms.litellm import LiteLLM
from ragbits_common.prompt import Prompt
from ragbits.common.llms.litellm import LiteLLM
from ragbits.common.prompt import Prompt


class LoremPromptInput(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-common/examples/prompt_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt


class LoremPromptInput(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-common/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers =
[options]
package_dir=
=src
packages=find:
packages=find_namespace:
zip_safe = False
platforms = any
include_package_data = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
except ImportError:
HAS_LITELLM = False

from ragbits_common.embeddings.base import Embeddings
from ragbits_common.embeddings.exceptions import EmbeddingConnectionError, EmbeddingResponseError, EmbeddingStatusError
from ragbits.common.embeddings.base import Embeddings
from ragbits.common.embeddings.exceptions import EmbeddingConnectionError, EmbeddingResponseError, EmbeddingStatusError


class LiteLLMEmbeddings(Embeddings):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import cached_property
from typing import Generic, Optional, Type, cast, overload

from ragbits_common.prompt.base import BasePrompt, BasePromptWithParser, OutputT
from ragbits.common.prompt.base import BasePrompt, BasePromptWithParser, OutputT

from .clients.base import LLMClient, LLMClientOptions, LLMOptions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pydantic import BaseModel

from ragbits_common.prompt import ChatFormat
from ragbits.common.prompt import ChatFormat

from ..types import NotGiven

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
HAS_LITELLM = False


from ragbits_common.prompt import ChatFormat
from ragbits.common.prompt import ChatFormat

from ..types import NOT_GIVEN, NotGiven
from .base import LLMClient, LLMOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
except ImportError:
HAS_LOCAL_LLM = False

from ragbits_common.prompt import ChatFormat
from ragbits.common.prompt import ChatFormat

from ..types import NOT_GIVEN, NotGiven
from .base import LLMClient, LLMOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
except ImportError:
HAS_LITELLM = False

from ragbits_common.prompt.base import BasePrompt
from ragbits.common.prompt.base import BasePrompt

from .base import LLM
from .clients.litellm import LiteLLMClient, LiteLLMOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
except ImportError:
HAS_LOCAL_LLM = False

from ragbits_common.prompt.base import BasePrompt
from ragbits.common.prompt.base import BasePrompt

from .base import LLM
from .clients.local import LocalLLMClient, LocalLLMOptions
Expand Down
3 changes: 3 additions & 0 deletions packages/ragbits-common/src/ragbits/common/prompt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ragbits.common.prompt.prompt import ChatFormat, Prompt

__all__ = ["Prompt", "ChatFormat"]
3 changes: 0 additions & 3 deletions packages/ragbits-common/src/ragbits_common/prompt/__init__.py

This file was deleted.

8 changes: 4 additions & 4 deletions packages/ragbits-common/tests/unit/llms/test_litellm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pydantic import BaseModel

from ragbits_common.llms.clients.litellm import LiteLLMOptions
from ragbits_common.llms.litellm import LiteLLM
from ragbits_common.prompt import Prompt
from ragbits_common.prompt.base import BasePrompt, BasePromptWithParser, ChatFormat
from ragbits.common.llms.clients.litellm import LiteLLMOptions
from ragbits.common.llms.litellm import LiteLLM
from ragbits.common.prompt import Prompt
from ragbits.common.prompt.base import BasePrompt, BasePromptWithParser, ChatFormat


class MockPrompt(BasePrompt):
Expand Down
4 changes: 2 additions & 2 deletions packages/ragbits-common/tests/unit/prompts/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from ragbits_common.prompt import Prompt
from ragbits_common.prompt.parsers import ResponseParsingError
from ragbits.common.prompt import Prompt
from ragbits.common.prompt.parsers import ResponseParsingError

from .test_prompt import _PromptOutput

Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-common/tests/unit/prompts/test_prompt.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pydantic
import pytest

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt


class _PromptInput(pydantic.BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-dev-kit/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers =
[options]
package_dir=
=src
packages=find:
packages=find_namespace:
zip_safe = False
platforms = any
include_package_data = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import jinja2
import typer
from pydantic import BaseModel
from ragbits_dev_kit.discovery.prompt_discovery import PromptDiscovery

from ragbits_common.llms import LiteLLM
from ragbits_common.llms.clients import LiteLLMOptions
from ragbits.common.llms import LiteLLM
from ragbits.common.llms.clients import LiteLLMOptions
from ragbits.dev_kit.discovery.prompt_discovery import PromptDiscovery


class PromptState:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ragbits.dev_kit.discovery.prompt_discovery import PromptDiscovery

__all__ = ["PromptDiscovery"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import namedtuple
from typing import Any

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt

PromptDetails = namedtuple("PromptDetails", ["system_prompt", "user_prompt", "input_type", "object"])

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt


class PromptForTestInput(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt


class PromptForTestInputA(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from ragbits_common.prompt import Prompt
from ragbits.common.prompt import Prompt


class PromptForTestInputB(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from pathlib import Path

from ragbits_dev_kit.discovery.prompt_discovery import PromptDiscovery
from ragbits.dev_kit.discovery.prompt_discovery import PromptDiscovery


def test_prompt_discovery_from_file():
Expand Down
9 changes: 4 additions & 5 deletions packages/ragbits-document-search/examples/simple_text.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import asyncio

from ragbits_document_search import DocumentSearch
from ragbits_document_search.documents.document import DocumentMeta
from ragbits_document_search.vector_store.in_memory import InMemoryVectorStore

from ragbits_common.embeddings.litellm import LiteLLMEmbeddings
from ragbits.common.embeddings.litellm import LiteLLMEmbeddings
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.vector_store.in_memory import InMemoryVectorStore

documents = [
DocumentMeta.create_text_document_from_literal("RIP boiled water. You will be mist."),
Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-document-search/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers =
[options]
package_dir=
=src
packages=find:
packages=find_namespace:
zip_safe = False
platforms = any
include_package_data = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from ragbits_document_search.documents.document import DocumentMeta
from ragbits_document_search.documents.element import Element
from ragbits_document_search.ingestion.document_processor import DocumentProcessor
from ragbits_document_search.retrieval.rephrasers.base import QueryRephraser
from ragbits_document_search.retrieval.rephrasers.noop import NoopQueryRephraser
from ragbits_document_search.retrieval.rerankers.base import Reranker
from ragbits_document_search.retrieval.rerankers.noop import NoopReranker
from ragbits_document_search.vector_store.base import VectorStore

from ragbits_common.embeddings.base import Embeddings
from ragbits.common.embeddings.base import Embeddings
from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.documents.element import Element
from ragbits.document_search.ingestion.document_processor import DocumentProcessor
from ragbits.document_search.retrieval.rephrasers.base import QueryRephraser
from ragbits.document_search.retrieval.rephrasers.noop import NoopQueryRephraser
from ragbits.document_search.retrieval.rerankers.base import Reranker
from ragbits.document_search.retrieval.rerankers.noop import NoopReranker
from ragbits.document_search.vector_store.base import VectorStore


class DocumentSearch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from typing import Union

from pydantic import BaseModel, Field
from ragbits_document_search.documents.sources import LocalFileSource

from ragbits.document_search.documents.sources import LocalFileSource


class DocumentType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from typing import ClassVar

from pydantic import BaseModel
from ragbits_document_search.documents.document import DocumentMeta
from ragbits_document_search.vector_store.base import VectorDBEntry

from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.vector_store.base import VectorDBEntry


class Element(BaseModel, ABC):
Expand All @@ -26,7 +27,7 @@ def get_key(self) -> str:
"""

@classmethod
def __pydantic_init_subclass__(cls, **kwargs): # pylint: disable=unused-argument
def __pydantic_init_subclass__(cls, **kwargs: dict) -> None: # pylint: disable=unused-argument
element_type_default = cls.model_fields["element_type"].default

if element_type_default is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from typing import List

from ragbits_document_search.documents.document import DocumentMeta, TextDocument
from ragbits_document_search.documents.element import Element, TextElement
from ragbits.document_search.documents.document import DocumentMeta, TextDocument
from ragbits.document_search.documents.element import Element, TextElement


class DocumentProcessor:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ragbits_document_search.retrieval.rephrasers.base import QueryRephraser
from ragbits.document_search.retrieval.rephrasers.base import QueryRephraser


class NoopQueryRephraser(QueryRephraser):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import abc

from ragbits_document_search.documents.element import Element
from ragbits.document_search.documents.element import Element


class Reranker(abc.ABC):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from ragbits_document_search.documents.element import Element
from ragbits_document_search.retrieval.rerankers.base import Reranker
from ragbits.document_search.documents.element import Element
from ragbits.document_search.retrieval.rerankers.base import Reranker


class NoopReranker(Reranker):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import numpy as np
from ragbits_document_search.vector_store.base import VectorDBEntry, VectorStore

from ragbits.document_search.vector_store.base import VectorDBEntry, VectorStore


class InMemoryVectorStore(VectorStore):
"""
A simple in-memory implementation of Vector Store, storing vectors in memory.
"""

def __init__(self):
self._storage = {}
def __init__(self) -> None:
self._storage: dict[str, VectorDBEntry] = {}

async def store(self, entries: list[VectorDBEntry]) -> None:
"""
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from unittest.mock import AsyncMock

from ragbits_document_search import DocumentSearch
from ragbits_document_search.documents.document import DocumentMeta
from ragbits_document_search.documents.element import TextElement
from ragbits_document_search.vector_store.in_memory import InMemoryVectorStore
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.document import DocumentMeta
from ragbits.document_search.documents.element import TextElement
from ragbits.document_search.vector_store.in_memory import InMemoryVectorStore


async def test_document_search():
Expand Down
4 changes: 2 additions & 2 deletions packages/ragbits-document-search/tests/unit/test_documents.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import tempfile
from pathlib import Path

from ragbits_document_search.documents.document import DocumentMeta, DocumentType, TextDocument
from ragbits_document_search.documents.sources import LocalFileSource
from ragbits.document_search.documents.document import DocumentMeta, DocumentType, TextDocument
from ragbits.document_search.documents.sources import LocalFileSource


async def test_loading_local_file_source():
Expand Down
6 changes: 3 additions & 3 deletions packages/ragbits-document-search/tests/unit/test_elements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ragbits_document_search.documents.document import DocumentType
from ragbits_document_search.documents.element import Element
from ragbits_document_search.vector_store.base import VectorDBEntry
from ragbits.document_search.documents.document import DocumentType
from ragbits.document_search.documents.element import Element
from ragbits.document_search.vector_store.base import VectorDBEntry


def test_resolving_element_type():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path

from ragbits_document_search.documents.document import DocumentMeta, DocumentType
from ragbits_document_search.documents.element import TextElement
from ragbits_document_search.documents.sources import LocalFileSource
from ragbits_document_search.vector_store.in_memory import InMemoryVectorStore
from ragbits.document_search.documents.document import DocumentMeta, DocumentType
from ragbits.document_search.documents.element import TextElement
from ragbits.document_search.documents.sources import LocalFileSource
from ragbits.document_search.vector_store.in_memory import InMemoryVectorStore


async def test_simple_vector_store():
Expand Down
Loading
Loading