slidedeckai.helpers.text_helper#


Utility functions to help with text processing.

fix_malformed_json

Try and fix the syntax error(s) in a JSON string.

get_clean_json

Attempt to clean a JSON response string from the LLM by removing `json at the beginning and trailing ` and any text beyond that.

is_valid_prompt

Verify whether user input satisfies the concerned constraints.

Utility functions to help with text processing.

slidedeckai.helpers.text_helper.fix_malformed_json(json_str: str) str[source]#

Try and fix the syntax error(s) in a JSON string.

Parameters:

json_str – The input JSON string.

Returns:

The fixed JSON string.

slidedeckai.helpers.text_helper.get_clean_json(json_str: str) str[source]#

Attempt to clean a JSON response string from the LLM by removing `json at the beginning and trailing ` and any text beyond that. CAUTION: May not be always accurate.

Parameters:

json_str – The input string in JSON format.

Returns:

The “cleaned” JSON string.

slidedeckai.helpers.text_helper.is_valid_prompt(prompt: str) bool[source]#

Verify whether user input satisfies the concerned constraints.

Parameters:

prompt – The user input text.

Returns:

True if all criteria are satisfied; False otherwise.