if __name__ == "__main__":
    documents = {
        "faq_returns.txt": (
            "Our return policy allows returns within 30 days of "
            "purchase with a valid receipt. Refunds are processed "
            "to the original payment method within 5 business days."
        ),
        "faq_shipping.txt": (
            "Standard shipping takes 5 to 7 business days. Express "
            "shipping is available for an additional fee and takes "
            "2 business days. International shipping times vary."
        ),
        "faq_account.txt": (
            "To reset your password, click forgot password on the "
            "login page and follow the instructions sent to your "
            "registered email address."
        ),
    }

    all_chunks = []
    for source, text in documents.items():
        all_chunks.extend(chunk_document(text, chunk_size=15))
    vocab = build_vocab(all_chunks)

    index = SimpleVectorIndex(vocab)
    for source, text in documents.items():
        for chunk_text in chunk_document(text, chunk_size=15):
            index.add(chunk_text, source)

    query = "How long do I have to return an item?"
    results = index.search(query, k=2)

    print("Retrieved chunks:")
    for chunk, score in results:
        print(f"  [{score:.3f}] ({chunk.source}) {chunk.text[:60]}...")

    prompt = build_rag_prompt(query, results)
    print("\nConstructed RAG prompt:\n")
    print(prompt)
