parse_answer_with_prefixes#
- langchain_cohere.react_multi_hop.parsing.parse_answer_with_prefixes(completion: str, prefixes: Dict[str, str]) Dict[str, str] [source]#
- parses string into key-value pairs,
according to patterns supplied in prefixes. Also strips.
- if inputs are:
completion = “
hello: sam goodbye then: paul.”,
prefixes = {“greeting”: “hello:”, “farewell”: “goodbye then:”}
- the expected returned result is:
{“greeting”: “sam”, “farewell”: “paul.”}
- Args:
completion (str): text to split prefixes (Dict[str, str]): a key-value dict of keys and patterns. See example above
- Returns:
Dict[str, str]: parsed result
- Parameters:
completion (str) –
prefixes (Dict[str, str]) –
- Return type:
Dict[str, str]