Skip to main content

Module

Utility functions for prompt template operations.

check_name_exists_in_organization

def check_name_exists_in_organization(name: str) -> bool
Check if a prompt template name exists in the organization. Enforces organization-wide uniqueness by checking global templates. Arguments
  • name (str): The template name to check.
Returns
  • bool: True if the name exists, False otherwise.

generate_unique_name

def generate_unique_name(base_name: str) -> str
Generate a unique template name by appending (N) if the base name exists. Ensures organization-wide uniqueness by checking global templates. Automatically increments the suffix until a unique name is found. Arguments
  • base_name (str): The desired template name.
Raises
  • ValueError: If unable to generate a unique name after 1000 attempts.
Returns
  • str: A unique name. Returns the original name if unique, otherwise appends (1), (2), etc.
Examples
  • If “my-template” doesn’t exist → returns “my-template”
  • If “my-template” exists → returns “my-template (1)”
  • If “my-template” and “my-template (1)” exist → returns “my-template (2)”