-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor registry api and file implementation * fix linting * directory registry refactoring * drop 3.10
- Loading branch information
Showing
15 changed files
with
216 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: 2023-present Massimiliano Pippi <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
from typing import Any, Protocol, Self | ||
|
||
from pydantic import BaseModel | ||
|
||
from .prompt import Prompt | ||
|
||
|
||
class PromptRegistry(Protocol): | ||
"""Interface to be implemented by concrete prompt registries.""" | ||
|
||
def get(self, *, name: str, version: str | None = None) -> Prompt: ... | ||
|
||
def set(self, *, prompt: Prompt, overwrite: bool = False) -> None: ... | ||
|
||
|
||
class PromptModel(BaseModel): | ||
"""Serializable representation of a Prompt.""" | ||
|
||
text: str | ||
name: str | None = None | ||
version: str | None = None | ||
metadata: dict[str, Any] | None = None | ||
|
||
@classmethod | ||
def from_prompt(cls: type[Self], prompt: Prompt) -> Self: | ||
return cls(text=prompt.raw, name=prompt.name, version=prompt.version, metadata=prompt.metadata) |
Oops, something went wrong.