# parse_answer_with_prefixes

> **Function** in `langchain_cohere`

📖 [View in docs](https://reference.langchain.com/python/langchain-cohere/react_multi_hop/parsing/parse_answer_with_prefixes)

Parses string into key-value pairs, according to patterns supplied in prefixes.

    Also strips.

    If inputs are:

    ```python
    completion = "
hello: sam
goodbye 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

## Signature

```python
parse_answer_with_prefixes(
    completion: str,
    prefixes: Dict[str, str],
) -> Dict[str, str]
```

---

[View source on GitHub](https://github.com/langchain-ai/langchain-cohere/blob/0e86adc8d140bf6e3da49836173bd5a50a194b63/libs/cohere/langchain_cohere/react_multi_hop/parsing.py#L96)