PromptTemplate Objects

class PromptTemplate(BasePromptTemplateResponse)

GlobalPromptTemplates Objects

class GlobalPromptTemplates(BaseClientModel)

update

def update(*, template_id: str, name: str) -> PromptTemplate
Update a global prompt template. Arguments:
  • template_id (str): The ID of the template to update.
  • name (str): The new name for the template.
Raises:
  • PromptTemplateAPIException: If the API request fails or returns an error.
Returns: PromptTemplate: The updated prompt template.

render_template

def render_template(*,
                    template: str,
                    data: Union[DatasetData, StringData],
                    starting_token: Union[Unset, int] = 0,
                    limit: Union[Unset, int] = 100) -> RenderTemplateResponse
Render a template with provided data. Arguments:
  • template (str): The template string to render.
  • data (Union[DatasetData, StringData]): The data to use for rendering the template. Can be either dataset data or string data.
  • starting_token (Union[Unset, int]): Starting token for pagination. Defaults to 0.
  • limit (Union[Unset, int]): Maximum number of rendered templates to return. Defaults to 100.
Raises:
  • PromptTemplateAPIException: If the API request fails or returns an error.
Returns: Optional[RenderTemplateResponse]: The rendered template response if successful, None otherwise.

get_prompt

def get_prompt(
        *,
        id: Optional[str] = None,
        name: Optional[str] = None,
        version: Optional[int] = None) -> Optional[PromptTemplateVersion]
Retrieves a specific global prompt template version. You must provide either ‘id’ or ‘name’, but not both. If ‘version’ is not provided, the currently selected version is returned. Arguments:
  • id (str): The unique identifier of the template to retrieve. Defaults to None.
  • name (str): The name of the template to retrieve. Defaults to None.
  • version (int): The version number to retrieve. If not provided, the currently selected version is returned. Defaults to None.
Raises:
  • ValueError: If neither or both ‘id’ and ‘name’ are provided.
Returns: Optional[PromptTemplateVersion]: The template version if found, None otherwise.

delete_prompt

def delete_prompt(*,
                  id: Optional[str] = None,
                  name: Optional[str] = None) -> None
Delete a global prompt template by ID or name. Arguments:
  • id (str): The unique identifier of the template to delete. Defaults to None.
  • name (str): The name of the template to delete. Defaults to None.
Raises:
  • ValueError: If neither or both id and name are provided, or if the template is not found.
Returns: None:

update_prompt

def update_prompt(*,
                  id: Optional[str] = None,
                  name: Optional[str] = None,
                  new_name: str) -> PromptTemplate
Update a global prompt template by ID or name. Arguments:
  • id (str): The unique identifier of the template to update. Defaults to None.
  • name (str): The name of the template to update. Defaults to None.
  • new_name (str): The new name for the template.
Raises:
  • ValueError: If neither or both id and name are provided, or if the template is not found.
  • PromptTemplateAPIException: If the API request fails or returns an error.
Returns: PromptTemplate: The updated prompt template.

create_prompt

def create_prompt(name: str, template: Union[list[Message],
                                             str]) -> PromptTemplate
Create a new global prompt template. Arguments:
  • name (str): The name for the new template.
  • template (Union[list[Message], str]): The template content. Can be either a list of Message objects or a JSON string representing the message structure.
Raises:
  • PromptTemplateAPIException: If the API request fails or returns an error.
Returns: PromptTemplate: The created prompt template.

get_prompts

def get_prompts(name_filter: Optional[str] = None,
                limit: Union[Unset, int] = 100) -> list[PromptTemplate]
List global prompt templates with optional filtering. Arguments:
  • name_filter (Optional[str]): Filter templates by name containing this string. Defaults to None (no filtering).
  • limit (Union[Unset, int]): Maximum number of templates to return. Defaults to 100.
Returns: list[PromptTemplate]: List of prompt templates matching the criteria.

render_template

def render_template(*,
                    template: str,
                    data: Union[DatasetData, StringData, list[str], str],
                    starting_token: Union[Unset, int] = 0,
                    limit: Union[Unset, int] = 100) -> RenderTemplateResponse
Render a template with provided data. Arguments:
  • template (str): The template string to render.
  • data (Union[DatasetData, StringData, list[str], str]): The data to use for rendering the template. Can be:
  • DatasetData: Reference to a dataset
  • StringData: List of input strings
  • list[str]: List of input strings (will be converted to StringData)
  • str: Dataset ID (will be converted to DatasetData)
  • starting_token (Union[Unset, int]): Starting token for pagination. Defaults to 0.
  • limit (Union[Unset, int]): Maximum number of rendered templates to return. Defaults to 100.
Raises:
  • PromptTemplateAPIException: If the API request fails or returns an error.
Returns: Optional[RenderTemplateResponse]: The rendered template response if successful, None otherwise.