Parses model-generated jsonified actions.
Expects input of the form
"{tool_use_prefix}: ```json
[{list of jsonified objects}]```"
outputs parsed list of jsonified objects.
Parse action selections from model output.
Parses a grounded_generation (from parse_actions) and documents (from
convert_to_documents) into a (generation, CohereCitation list) tuple.
Cohere has fine-grained citations that specify the exact part of text.
More info at https://docs.cohere.com/docs/documents-and-citations
Parses a message into agent actions/finish.
Parses string into key-value pairs, according to patterns supplied in prefixes.
Also strips.
If inputs are:
completion = "
o: sam
bye then: paul.",
prefixes = {"greeting": "hello:", "farewell": "goodbye then:"}
... the expected returned result is:
`{"greeting": "sam", "farewell": "paul."}`
Args:
completion: Text to split
prefixes: A key-value dict of keys and patterns.
See example above
Returns:
Parsed result