Skip to content

Commit

Permalink
remove save from the protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Jun 3, 2024
1 parent 3c3e999 commit 28348b7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/banks/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def _add_default_templates(r: TemplateRegistry):
templates_dir = Path(os.path.dirname(__file__)) / "templates"
for tpl_file in templates_dir.glob("*.jinja"):
r.set(name=tpl_file.name, prompt=tpl_file.read_text())
r.save()


# Init the Jinja env
Expand Down
3 changes: 2 additions & 1 deletion src/banks/registries/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def set(self, *, name: str, prompt: str, version: str | None = None, overwrite:
tpl = self.get(name, version)
if overwrite:
tpl.prompt = prompt
return
self.save()
except TemplateNotFoundError:
tpl_id = self._make_id(name, version)
tpl = PromptTemplate(id=tpl_id, name=name, version=version or "", prompt=prompt)
self._index.templates.append(tpl)
self.save()
2 changes: 0 additions & 2 deletions src/banks/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class PromptTemplateIndex(BaseModel):


class TemplateRegistry(Protocol):
def save(self) -> None: ...

def get(self, *, name: str, version: str | None = None) -> "PromptTemplate": ...

def set(self, *, name: str, prompt: str, version: str | None = None, overwrite: bool = False): ...

0 comments on commit 28348b7

Please sign in to comment.