"""Keep changing policy facts separate from a stable response template."""
import json

POLICY = {'hotel_limit_eur': 160, 'exception': 'written manager approval before booking'}


def policy_passage(policy):
    """Build the evidence text from the policy record, so an edit changes the passage."""
    return {'source': 'handbook.pdf', 'page': 2, 'text': f"Hotel limit: EUR {policy['hotel_limit_eur']} per night; higher limits require {policy['exception']}."}


def build_messages(question, passages):
    return [
        {'role': 'system', 'content': 'Use the provided passages only. Give a short answer followed by its source. If they do not answer the question, say so.'},
        {'role': 'user', 'content': json.dumps({'question': question, 'passages': passages})},
    ]


if __name__ == '__main__':
    print(json.dumps(build_messages('What is the hotel limit?', [policy_passage(POLICY)]), indent=2))
