Skip to content

prompts

Classes

PromptsClient

PromptsClient(client: OWUIClientBase)

Bases: ResourceBase

Client for the Prompts endpoints.

Source code in src/owui_client/client_base.py
def __init__(self, client: OWUIClientBase):
    self._client = client

Functions

get_prompts
get_prompts() -> List[PromptModel]

Get all prompts (read access).

Returns:

Type Description
List[PromptModel]

List[PromptModel]: List of prompts.

Source code in src/owui_client/routers/prompts.py
async def get_prompts(self) -> List[PromptModel]:
    """
    Get all prompts (read access).

    Returns:
        List[PromptModel]: List of prompts.
    """
    return await self._request(
        "GET", "/v1/prompts/", model=List[PromptModel]
    )
get_prompt_list
get_prompt_list() -> List[PromptUserResponse]

Get all prompts with user info (write access).

Returns:

Type Description
List[PromptUserResponse]

List[PromptUserResponse]: List of prompts with user details.

Source code in src/owui_client/routers/prompts.py
async def get_prompt_list(self) -> List[PromptUserResponse]:
    """
    Get all prompts with user info (write access).

    Returns:
        List[PromptUserResponse]: List of prompts with user details.
    """
    return await self._request(
        "GET", "/v1/prompts/list", model=List[PromptUserResponse]
    )
create_new_prompt
create_new_prompt(
    form_data: PromptForm,
) -> Optional[PromptModel]

Create a new prompt.

Parameters:

Name Type Description Default
form_data PromptForm

The prompt data. The command field must start with a slash (e.g., '/help').

required

Returns:

Type Description
Optional[PromptModel]

Optional[PromptModel]: The created prompt.

Source code in src/owui_client/routers/prompts.py
async def create_new_prompt(self, form_data: PromptForm) -> Optional[PromptModel]:
    """
    Create a new prompt.

    Args:
        form_data: The prompt data. The `command` field must start with a slash (e.g., '/help').

    Returns:
        Optional[PromptModel]: The created prompt.
    """
    return await self._request(
        "POST",
        "/v1/prompts/create",
        json=form_data.model_dump(),
        model=Optional[PromptModel],
    )
get_prompt_by_command
get_prompt_by_command(
    command: str,
) -> Optional[PromptModel]

Get a prompt by command.

Parameters:

Name Type Description Default
command str

The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.

required

Returns:

Type Description
Optional[PromptModel]

Optional[PromptModel]: The prompt details.

Source code in src/owui_client/routers/prompts.py
async def get_prompt_by_command(self, command: str) -> Optional[PromptModel]:
    """
    Get a prompt by command.

    Args:
        command: The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.

    Returns:
        Optional[PromptModel]: The prompt details.
    """
    clean_command = command.lstrip("/")
    return await self._request(
        "GET",
        f"/v1/prompts/command/{clean_command}",
        model=Optional[PromptModel],
    )
update_prompt_by_command
update_prompt_by_command(
    command: str, form_data: PromptForm
) -> Optional[PromptModel]

Update a prompt by command.

Parameters:

Name Type Description Default
command str

The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.

required
form_data PromptForm

The updated prompt data.

required

Returns:

Type Description
Optional[PromptModel]

Optional[PromptModel]: The updated prompt.

Source code in src/owui_client/routers/prompts.py
async def update_prompt_by_command(
    self, command: str, form_data: PromptForm
) -> Optional[PromptModel]:
    """
    Update a prompt by command.

    Args:
        command: The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.
        form_data: The updated prompt data.

    Returns:
        Optional[PromptModel]: The updated prompt.
    """
    clean_command = command.lstrip("/")
    return await self._request(
        "POST",
        f"/v1/prompts/command/{clean_command}/update",
        json=form_data.model_dump(),
        model=Optional[PromptModel],
    )
delete_prompt_by_command
delete_prompt_by_command(command: str) -> bool

Delete a prompt by command.

Parameters:

Name Type Description Default
command str

The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.

required

Returns:

Name Type Description
bool bool

True if successful.

Source code in src/owui_client/routers/prompts.py
async def delete_prompt_by_command(self, command: str) -> bool:
    """
    Delete a prompt by command.

    Args:
        command: The command trigger (e.g., 'help' or '/help'). Leading slash is automatically handled.

    Returns:
        bool: True if successful.
    """
    clean_command = command.lstrip("/")
    return await self._request(
        "DELETE",
        f"/v1/prompts/command/{clean_command}/delete",
        model=bool,
    )