Project: Build a Policy Q&A Assistant for Your Team

Project: Build a Policy Q&A Assistant for Your Team 1
⏱ 2 min readUpdated 13 October 2026

📘 AI Agents & RAG Course · Lesson 7 of 7

In this article
  1. The pieces
  2. The web app
  3. Before you share it
  4. Where to go next

Time to assemble everything into something colleagues can use: a simple web page where anyone types a question about company policy and gets an answer with sources.

Advertisement

The pieces

  • Documents: export policies as .txt (or extract PDF text) into a policies folder.
  • Index: chunking + BM25 from Lessons 3–4, with your measured threshold.
  • Agent: the search + calculator tools from Lesson 5.
  • Guardrails: turn cap, cost cap and logging from Lesson 6.
  • Web page: a tiny Flask app.

The web app

pip install flask

from flask import Flask, request, render_template_string
app = Flask(__name__)
PAGE = """<!doctype html><title>Policy helper</title>
<form method=post><input name=q size=60 autofocus placeholder="Ask about leave, travel, expenses...">
<button>Ask</button></form>{% if a %}<h3>{{ q }}</h3><p style="white-space:pre-wrap">{{ a }}</p>{% endif %}"""

@app.route("/", methods=["GET", "POST"])
def home():
    q = request.form.get("q", "").strip()
    a = run_agent(q) if q else ""     # the guarded loop from Lesson 6
    return render_template_string(PAGE, q=q, a=a)

app.run(port=8000)

Before you share it

  1. Run your test set from Lesson 4 — every answerable question should cite the right document, every unanswerable one should say “I don’t know”.
  2. Ask three colleagues to try to break it, including asking about things that aren’t in the policies.
  3. Agree who updates the documents and how often the index is rebuilt.
  4. Keep it on your internal network; never expose the API key in the page.

Where to go next

  • Swap BM25 for hybrid search and compare on the same test set.
  • Add a “Was this helpful?” button and log it.
  • Index Excel files by turning each row into a sentence (“Employee grade L3: daily allowance ₹2,500 in metro cities”).

Congratulations — you have built the core of most “chat with your documents” products, and you understand exactly what happens inside them.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong