def QA_format_preprocessor(inp: dict) -> ChatFormattedDict:
    """Convert from QA format to our chat format."""
    try:
        Q = inp['Q']
        A = inp['A']
        messages: list[dict[str, str]] = [{
            'role': 'user',
            'content': Q,
        }, {
            'role': 'assistant',
            'content': A,
        }]
    except Exception as e:
        raise UnableToProcessPromptResponseError(inp) from e
    return {'messages': messages}
Convert from QA format to our chat format.
llmfoundry/data/finetuning/tasks.py