Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed May 28, 2024
1 parent dcc665f commit 092ea9d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/banks/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

@runtime_checkable
class RenderCache(Protocol):
"""
Interface for rendering cache.
Prompts with the same template and same context are retrieved from the cache directly,
instead of going through the rendering process.
"""

def get(self, context: dict) -> Optional[str]: ...

def set(self, context: dict, prompt: str) -> None: ...
Expand All @@ -15,6 +22,10 @@ def clear(self) -> None: ...


class DefaultCache:
"""
In-memory, default rendering cache.
"""

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

Expand Down

0 comments on commit 092ea9d

Please sign in to comment.