Skip to content

Commit

Permalink
fix(typos): deprecate Interruptable in favor of Interruptible
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Feb 7, 2025
1 parent a3c155a commit aee5087
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
10 changes: 5 additions & 5 deletions python/promplate/chain/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ..prompt import Context

if TYPE_CHECKING:
from .node import AsyncProcess, ChainContext, Interruptable, Process
from .node import AsyncProcess, ChainContext, Interruptible, Process


class BaseCallback(Protocol):
Expand All @@ -13,10 +13,10 @@ def mid_process(self, context: "ChainContext") -> Context | Awaitable[Context |

def end_process(self, context: "ChainContext") -> Context | Awaitable[Context | None] | None: ...

def on_enter(self, node: "Interruptable", context: Context | None, config: Context) -> tuple[Context | None, Context]:
def on_enter(self, node: "Interruptible", context: Context | None, config: Context) -> tuple[Context | None, Context]:
return context, config

def on_leave(self, node: "Interruptable", context: "ChainContext", config: Context) -> tuple["ChainContext", Context]:
def on_leave(self, node: "Interruptible", context: "ChainContext", config: Context) -> tuple["ChainContext", Context]:
return context, config


Expand All @@ -27,8 +27,8 @@ def __init__(
pre_process: "Process | AsyncProcess | None" = None,
mid_process: "Process | AsyncProcess | None" = None,
end_process: "Process | AsyncProcess | None" = None,
on_enter: Callable[["Interruptable", Context | None, Context], tuple[Context | None, Context]] | None = None,
on_leave: Callable[["Interruptable", "ChainContext", Context], tuple["ChainContext", Context]] | None = None,
on_enter: Callable[["Interruptible", Context | None, Context], tuple[Context | None, Context]] | None = None,
on_leave: Callable[["Interruptible", "ChainContext", Context], tuple["ChainContext", Context]] | None = None,
):
self._pre_process = pre_process
self._mid_process = mid_process
Expand Down
22 changes: 16 additions & 6 deletions python/promplate/chain/node.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from inspect import isclass
from itertools import accumulate
from typing import Callable, Mapping, MutableMapping, TypeVar, overload
from typing import TYPE_CHECKING, Callable, Mapping, MutableMapping, TypeVar, overload

from ..llm.base import *
from ..prompt.template import Context, Loader, SafeChainMapContext, Template
Expand Down Expand Up @@ -105,7 +105,7 @@ def ensure_callbacks(callbacks: list[BaseCallback | type[BaseCallback]]) -> list
return [i() if isclass(i) else i for i in callbacks]


class Interruptable(AbstractNode, Protocol):
class Interruptible(AbstractNode, Protocol):
def _invoke(
self,
context: ChainContext,
Expand Down Expand Up @@ -301,7 +301,17 @@ def context(self):
self._context = None


class Node(Loader, Interruptable):
if TYPE_CHECKING:
from typing_extensions import deprecated # type: ignore

@deprecated("Use `Interruptible` instead")
class Interruptable(Interruptible, Protocol): ...

else:
Interruptable = Interruptible


class Node(Loader, Interruptible):
def __init__(
self,
template: Template | str,
Expand Down Expand Up @@ -383,7 +393,7 @@ def __str__(self):
return f"</{self.name}/>"


class Loop(Interruptable):
class Loop(Interruptible):
def __init__(self, chain: AbstractNode, partial_context: Context | None = None):
self.chain = chain
self._context = partial_context
Expand Down Expand Up @@ -420,7 +430,7 @@ async def _astream(self, context, /, generate, callbacks, **config):
await self._apply_async_end_processes(context, callbacks)


class Chain(Interruptable):
class Chain(Interruptible):
def __init__(self, *nodes: AbstractNode, partial_context: Context | None = None):
self.nodes = list(nodes)
self._context = partial_context
Expand Down Expand Up @@ -472,7 +482,7 @@ def __repr__(self):


class Jump(Exception):
def __init__(self, into: Interruptable | None = None, out_of: Interruptable | None = None):
def __init__(self, into: Interruptible | None = None, out_of: Interruptible | None = None):
self.into = into
self.out_of = out_of

Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "promplate"
version = "0.3.5.0"
version = "0.3.5.1"
description = "Prompt engineering framework for humans"
homepage = "https://promplate.dev/"
documentation = "https://docs.py.promplate.dev/"
Expand Down

0 comments on commit aee5087

Please sign in to comment.