Skip to content

Commit

Permalink
fix linting problems
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Apr 27, 2024
1 parent 8eb6873 commit 51be2c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ exclude_lines = [
[[tool.mypy.overrides]]
module = [
"simplemma.*",
"litellm.*"
"litellm.*",
"distutils.*",
]
ignore_missing_imports = true
11 changes: 7 additions & 4 deletions src/banks/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
from banks.errors import AsyncError


class Prompt:
class BasePrompt:
def __init__(self, text: str) -> None:
self._template = env.from_string(text)

@classmethod
def from_template(cls, name: str) -> "Prompt":
def from_template(cls, name: str) -> "BasePrompt":
p = cls("")
p._template = env.get_template(name)
return p


class Prompt(BasePrompt):
def text(self, data: Optional[dict] = None) -> str:
data = data or {}
return self._template.render(data)


class AsyncPrompt(Prompt):
class AsyncPrompt(BasePrompt):
def __init__(self, text: str) -> None:
super().__init__(text)

Expand All @@ -32,4 +34,5 @@ def __init__(self, text: str) -> None:

async def text(self, data: Optional[dict] = None) -> str:
data = data or {}
return await self._template.render_async(data)
result: str = await self._template.render_async(data)
return result

0 comments on commit 51be2c7

Please sign in to comment.