GlobalPromptTemplates
create
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.project_id(Optional[str]): The project ID to associate with this template. Defaults to None.project_name(Optional[str]): The project name to associate with this template. Defaults to None. Cannot be used together with project_id.
PromptTemplateAPIException: If the API request fails or returns an error.ValueError: If both project_id and project_name are provided, or if project_name doesn’t exist.
PromptTemplate: The created prompt template.
delete
template_id(Optional[str]): The unique identifier of the template to delete. Defaults to None.name(Optional[str]): The name of the template to delete. Defaults to None.
ValueError: If neither or both template_id and name are provided, or if the template is not found.
list
name_filter(Optional[str]): Filter templates by name containing this string. Defaults to None.project_id(Optional[str]): Filter templates by project ID. Returns templates used in the specified project. Defaults to None.project_name(Optional[str]): Filter templates by project name. Returns templates used in the specified project. Defaults to None. Cannot be used together with project_id.limit(Union[Unset, int]): Maximum number of templates to return. Defaults to 100.starting_token(int): Starting token for pagination. Defaults to 0.
ValueError: If both project_id and project_name are provided, or if project_name doesn’t exist.
list[PromptTemplate]: List of prompt templates matching the criteria.
render_template
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.
PromptTemplateAPIException: If the API request fails or returns an error.
Optional[RenderTemplateResponse]: The rendered template response if successful, None otherwise.
update
template_id(str): The ID of the template to update.name(str): The new name for the template.
PromptTemplateAPIException: If the API request fails or returns an error.
PromptTemplate: The updated prompt template.
PromptTemplates
Class for managing project-specific prompt templates.Deprecated. This class is deprecated as templates are now global. Use the module-level
functions
get_prompts, create_prompt, etc. instead.
This class will be removed in a future version.create
name(str): The template name.template(Union[list[Message], str]): The template content.
PromptTemplate: The created template.
delete
name(str): The template name.
get
name(str): The template name.
Optional[PromptTemplate]: The template if found, None otherwise.
list
list[PromptTemplate]: List of templates associated with the project.
create_prompt
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.project_id(Optional[str]): The project ID to associate with this template. When provided, the template will be linked to the specified project. Defaults to None.project_name(Optional[str]): The project name to associate with this template. When provided, the template will be linked to the specified project. Defaults to None. Cannot be used together with project_id.
PromptTemplateAPIException: If the API request fails or returns an error.ValueError: If both project_id and project_name are provided, or if project_name doesn’t exist.
PromptTemplate: The created prompt template.
create_prompt_template
Deprecated. Use
create_prompt instead.name(str): The name for the new template.project(str): The project name to associate with this template.messages(list[Message]): The template content as a list of Message objects.
PromptTemplateAPIException: If the API request fails or returns an error.ValueError: If project doesn’t exist.
PromptTemplate: The created prompt template.
delete_prompt
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.project_id(str): Deprecated. This parameter is ignored.project_name(str): Deprecated. This parameter is ignored.
ValueError: If neither or both id and name are provided, or if the template is not found.
None:
get_prompt
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.project_id(str): Deprecated. This parameter is ignored. Use get_prompts(project_id=…) to filter templates by project.project_name(str): Deprecated. This parameter is ignored. Use get_prompts(project_name=…) to filter templates by project.
ValueError: If neither or both ‘id’ and ‘name’ are provided.
Optional[PromptTemplate]: The template if found, None otherwise.
get_prompt_template
Deprecated. Use
get_prompt with name parameter or get_prompts with
project_name parameter instead. This function is deprecated and will be
removed in a future version.name(str): The name of the template.project(str): The project name (ignored - templates are now global).
Optional[PromptTemplate]: The template if found, None otherwise.
get_prompts
name_filter(Optional[str]): Filter templates by name containing this string. Defaults to None (no filtering).project_id(Optional[str]): Filter templates by project ID. Returns templates used in the specified project. Defaults to None.project_name(Optional[str]): Filter templates by project name. Returns templates used in the specified project. Defaults to None. Cannot be used together with project_id.limit(Union[Unset, int]): Maximum number of templates to return. Defaults to 100.
ValueError: If both project_id and project_name are provided, or if project_name doesn’t exist.
list[PromptTemplate]: List of prompt templates matching the criteria.
list_prompt_templates
Deprecated. Use
get_prompts with project_name parameter instead.
This function is deprecated and will be removed in a future version.project(str): The project name to filter templates by.
list[PromptTemplate]: List of prompt templates associated with the project.
render_template
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.
PromptTemplateAPIException: If the API request fails or returns an error.
Optional[RenderTemplateResponse]: The rendered template response if successful, None otherwise.
update_prompt
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.
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.
PromptTemplate: The updated prompt template.