Prompt Methods
- is_detached(self) bool
Check if the fetched prompt is in offline mode.
- Returns:
bool: True if the fetched prompt is offline and headless, False otherwise.
- Raises:
ClientError: If the fetched prompt mode is not ‘detached’.
Example:
prompt.is_offline()
- get_info(self, verbose=False)
Get info of the fetched prompt.
This method retrieves all available details of the fetched prompt and returns them as a dictionary.
- Args:
verbose (bool): If True, include all details. Default is False.
- Returns:
dict: A dictionary containing the prompt details.
- Raises:
ValueError: If no prompt data is available.
- get_prompt_variables(self) str
Get the prompt variables of the fetched prompt.
This method retrieves the prompt variables from the fetched prompt.
- Returns:
str: A string representation of the prompt variables.
- Raises:
ValueError: If no prompt data is available.
Example:
prompt.get_prompt_variables()
- update_prompt_variables(self, prompt_variables: dict)
Update the prompt variables for the prompt.
This method takes a dictionary of prompt variables and updates the prompt variables of the prompt.
- Parameters:
prompt_variables (dict): A dictionary containing the new prompt variables.
Example:
prompt.update_prompt_variables(prompt_variables={"text": {}})
- update_prompt_name(self, name: str)
Update or set the name of the Prompt.
This method allows the setting or updating of the prompt ‘name’ to a new value.
- Parameters:
name (str): The new name to assign to the instance. This should be a non-empty string.
Example:
prompt.update_prompt_name(name="NewName")
- update_prompt_description(self, prompt_description: str)
Update or set the description of the prompt.
This method allows for the setting or updating of prompt description to a new value.
- Parameters:
prompt_description (str): The new description to assign to the external prompt.
Example:
prompt.update_prompt_description(prompt_description="description")
- update_prompt_attribute(self, key_name: str, value: Any)
Update a specific attribute of the fetched prompt.
This method updates a any attribute of the fetched prompt with the provided key name and value.
- Parameters:
key_name (str): The name of the attribute to be updated. value (Any): The new value for the attribute. It can be of any type.
- Raises:
ClientError: If the update operation fails.
Example:
prompt.update_prompt_attribute(key_name="task_id", value="Next steps")
Attention
update_prompt_attribute is only supported for Regular prompts, not for Detached prompt