# 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/98e3d038d365eebd6dabcf8c4d94072580f7401d/libs/cohere/langchain_cohere/react_multi_hop/parsing.py#L96)