Skip to content
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
2 changes: 1 addition & 1 deletion elroy/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
P = ParamSpec("P")


def db(f: Callable[P, T]) -> Callable[P, T]:
def db[**P, T](f: Callable[P, T]) -> Callable[P, T]:
"""Decorator to wrap non-generator function calls with database session context"""

@wraps(f)
Expand Down
4 changes: 2 additions & 2 deletions elroy/llm/stream_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from abc import ABC, abstractmethod
from collections.abc import Generator, Iterator
from dataclasses import dataclass
from typing import Generic, TypeVar
from typing import TypeVar

from litellm.types.utils import Delta, ModelResponse
from pydantic import BaseModel
Expand Down Expand Up @@ -84,7 +84,7 @@ class TagSet:
T = TypeVar("T", bound=BaseModel)


class TextProcessor(ABC, Generic[T]):
class TextProcessor[T: BaseModel](ABC):
tags: list[TagSet]

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion elroy/repository/context_messages/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def replace_context_messages(ctx: ElroyContext, messages: Iterable[ContextMessag
T = TypeVar("T")


def retry_on_integrity_error(fn: Callable[..., T]) -> Callable[..., T]:
def retry_on_integrity_error[T](fn: Callable[..., T]) -> Callable[..., T]:
@wraps(fn)
def wrapper(ctx: ElroyContext, *args: Any, **kwargs: Any) -> T:
max_retries = 3
Expand Down
2 changes: 1 addition & 1 deletion elroy/repository/recall/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def is_in_context(context_messages: Iterable[ContextMessage], memory: Embeddable


@tracer.chain
def query_vector(
def query_vector[T: EmbeddableSqlModel](
table: type[T],
ctx: ElroyContext,
query: list[float],
Expand Down
2 changes: 1 addition & 1 deletion elroy/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def first_or_none(x: Union[Iterator[T], Iterable[T]]) -> Optional[T]: # noqa
raise ValueError(f"Expected an iterable or iterator, got {x}")


def last_or_none(iterable: Iterator[T]) -> T | None:
def last_or_none[T](iterable: Iterator[T]) -> T | None:
return next(reversed(list(iterable)), None)


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ elroy = "elroy.cli.main:app"

[tool.ruff]
line-length = 140
target-version = "py311"
target-version = "py312"

[tool.ruff.lint]
select = [
Expand All @@ -100,7 +100,7 @@ quote-style = "double"
indent-style = "space"

[tool.ty.environment]
python-version = "3.11"
python-version = "3.12"

[tool.ty.src]
include = ["elroy/**/*.py", "tests/**/*.py"]
Expand Down