adding GET /prompts/{prompt_id}/versions

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-09-04 21:45:04 -04:00
parent 5f3425bb1b
commit 5c02661b79
5 changed files with 147 additions and 1 deletions

View file

@ -21,6 +21,7 @@ class Prompt(BaseModel):
:param version: Version string (integer start at 1 cast as string, incremented on save)
:param prompt_id: Unique identifier formatted as 'pmpt_<48-digit-hash>'
:param variables: Dictionary of prompt variable names and values
:param is_default: Boolean indicating whether this version is the default version for this prompt
"""
prompt: str | None = Field(default=None, description="The system prompt with variable placeholders")
@ -29,6 +30,9 @@ class Prompt(BaseModel):
variables: dict[str, str] | None = Field(
default_factory=dict, description="Variables for dynamic injection using {{variable}} syntax"
)
is_default: bool = Field(
default=False, description="Boolean indicating whether this version is the default version"
)
@field_validator("prompt_id")
@classmethod
@ -158,6 +162,18 @@ class Prompts(Protocol):
"""
...
@webmethod(route="/prompts/{prompt_id:path}/versions", method="GET")
async def list_prompt_versions(
self,
prompt_id: str,
) -> ListPromptsResponse:
"""List all versions of a specific prompt.
:param prompt_id: The identifier of the prompt to list versions for.
:returns: A ListPromptsResponse containing all versions of the prompt.
"""
...
@webmethod(route="/prompts/{prompt_id:path}/default-version", method="PUT")
async def set_default_version(
self,