Output Parsing
Output parser
llama_cpp_agent.output_parser
is_empty_or_whitespace(s)
Checks if a string is empty or contains only whitespace.
Parameters:
-
s(str) –The input string.
Returns:
-
bool–True if the string is empty or contains only whitespace, False otherwise.
Source code in llama_cpp_agent/output_parser.py
parse_json_response(response)
Parses a JSON response string.
Parameters:
-
response(str) –The JSON response string.
Returns:
-
dict–The parsed JSON object.
Source code in llama_cpp_agent/output_parser.py
parse_json_response_with_markdown_code_block_or_triple_quoted_string(json_response, marker)
Parses a JSON response string followed by a Markdown code block or triple-quoted string.
Parameters:
-
json_response(str) –The JSON response string followed by a Markdown code block or triple-quoted string.
-
marker(str) –Triple quotes (''') or triple back ticks (```)
Returns:
-
–
Tuple[dict, str]: The parsed JSON object and the content of the Markdown code block or triple-quoted string.
Source code in llama_cpp_agent/output_parser.py
extract_object_from_response(response, object_clas)
Extracts an object of the specified class from a JSON response string.
Parameters:
-
response(str) –The JSON response string.
-
object_clas(type) –The class of the object to be extracted.
Returns:
-
object_clas–An instance of the specified class.