All projects

LLMs, RAG & Agents

Event Recommendation Assistant

Case study: A cultural events platform

Ask a question in plain words and get event suggestions drawn from a real events agenda, with the sources listed under the answer.

Ask about upcoming events
Real model output
A real answer of the model, recorded again every Monday, written from the 5 passages the search found first.

The problem

Case study: a cultural events platform wants a chatbot that can answer questions like "any jazz concerts in Bordeaux?". A language model on its own answers from memory, and it will happily invent a concert that does not exist. The assistant has to stick to the platform's real listings, show where each answer comes from, and admit when nothing fits.

For this portfolio, I reworked the first version: the original data had gone stale, dates and places were not understood, and the answers were always in French.

What the demo does

You type a question or tap one of the suggestions. The assistant searches the upcoming cultural events of a region in south-west France (public OpenAgenda data, rebuilt every week), keeps the 5 passages closest in meaning to your question, and has a Mistral model write the answer from those passages only, in the language of your question. Dates and places are understood: "this weekend", "in November", "in Limoges", "in Corrèze".

Under the answer, each event it used appears as a card with a link to the original listing. The "See what the AI read" button opens the 5 retrieved passages with their similarity score. That panel shows the idea behind RAG (retrieval-augmented generation) on one screen: the system finds first, then writes.

The listings are in French, so event titles and venues appear as published.

Ask about upcoming events

Results

0.98Faithfulness
On 20 questions I annotated by hand, 98% of the statements in the answers are backed by the events the search retrieved.
0.89Context precision
Checks whether the passages the search puts first are the useful ones. The original pipeline scored 0.73 on the same questions.
93%Expected event in the top 5
For 93% of the questions, an event I marked as relevant by hand is among the 5 passages the search returns. No language model is involved in this measure.
100%Dates and places respected
Every event shown falls within the period and the place the visitor asked for ("this weekend", "in Limoges"). The original pipeline kept to the period only 43% of the time.

I wrote a new test set for this version: 20 questions annotated by hand (9 in English, 11 in French), with the relevant events marked for each one. To measure what my changes bring, I also ran the original pipeline on the same 20 questions, with the same index, the same answer model and the same judge. Only the pipeline differs.

Measure Original pipeline Current version
Faithfulness 0.88 0.98
Answer relevancy 0.81 0.88
Context precision 0.73 0.89
Expected event in the top 5 80% 93%
Answer in the language of the question 59% 100%
Sources within the requested period 43% 100%
Sources in the requested place 93% 100%

Off-topic questions and prompt injections are declined every time. The first word appears after 1.1 s on median, and a question costs about $0.00035.

Data on 6 October 2026: 5,109 upcoming events retrieved, 3,596 kept after cleaning, 2,289 served once job and training agendas and cancelled events are left out, split into 6,128 passages. Building the index costs $0.12 of embeddings.

The first version was evaluated with Ragas on 10 questions and data from May 2026: faithfulness 0.83, answer relevancy 0.83, context precision 0.82.

Limits:

  • With 20 questions, a gap of 0.05 is one or two questions.
  • The judge is my own, built on the Ragas definitions, because Ragas did not import in Python 3.12. Checked on the 10 answers of the first version, it is more lenient than Ragas on faithfulness (1.00 against 0.83) and close to it on context precision (0.81 against 0.82). The comparison above stays fair: both pipelines go through the same judge.

How it's built

Architecture, stack and technical choices.
Architecture

Question (POST /ask/stream)

Weekly refresh (cron)

swap

OpenAgenda API
upcoming events

Clean and
deduplicate

Split into passages

Mistral embeddings

FAISS index

Gate
6 checks

Visitor

FastAPI
guardrails

Date and place
filters

Top 5 passages

Mistral model
with fallback

Answer, sources,
passages read

Diagram as text
flowchart LR
    subgraph Refresh["Weekly refresh (cron)"]
        A["OpenAgenda API<br/>upcoming events"] --> B["Clean and<br/>deduplicate"] --> C["Split into passages"] --> D["Mistral embeddings"] --> E[("FAISS index")] --> Q{"Gate<br/>6 checks"}
    end
    subgraph Answering["Question (POST /ask/stream)"]
        U["Visitor"] --> F["FastAPI<br/>guardrails"] --> P["Date and place<br/>filters"] --> G["Top 5 passages"] --> H["Mistral model<br/>with fallback"] --> R["Answer, sources,<br/>passages read"]
    end
    Q -.->|"swap"| G

Stack

  • Python
  • LangChain
  • FAISS
  • Mistral AI
  • FastAPI
  • Pydantic
  • Ragas
  • Pytest
  • Docker
  • uv
  • Ingestion: the OpenAgenda open data API, Nouvelle-Aquitaine region, events not finished yet. The API pages through 10,000 records at most, so a larger query is split by department. HTML stripped, events without a title, description or date dropped, duplicates removed by ID.
  • Indexing: each event becomes a LangChain document (title, category, keywords, venue, description, upcoming dates) with its metadata kept alongside (dates, city, URL). Documents are split into 1,000-character chunks with a 200-character overlap, embedded with mistral-embed (1,024 dimensions) and stored in a flat FAISS index on disk.
  • Answering: dates and places in the question are turned into filters on the real dates and towns of the events. FAISS ranks the passages by cosine similarity, then the 300 closest are lightly re-ranked on the words of the question (weight 0.03, fixed in advance). The model gets the 5 best passages and today's date, answers at temperature 0.3 from those passages only, and declines off-topic questions. Models are tried in order with an automatic fallback: one that answers 429 or 403 is set aside for 10 minutes, doubled at each failure, 6 hours at most.
  • API: FastAPI with /ask, /ask/stream (Server-Sent Events: the sources and passages arrive before the answer), /suggestions, /recorded (answers to the suggested questions, recorded again every Monday for the home page preview), /health and /rebuild (admin key). Guardrails run before any paid call: question of 300 characters at most, prompt-injection filter in English and French, cache for the suggested questions, 6 questions a minute and 40 a day per IP, 25 a minute overall, and a daily budget of €0.08 (about 230 questions).
  • Weekly refresh: a cron job runs scripts/refresh.sh in a one-off container. It fetches the events, builds the new index in a staging folder, runs 6 deterministic checks, then swaps. The running API reloads the new index without restarting, the previous version is kept for a rollback, and disk use stays flat: the index is rebuilt, never appended to.
  • Delivery: Docker (non-root user, 512 MB memory cap, port bound to localhost behind Caddy), dependencies locked with uv, 75 Pytest tests and an end-to-end browser test.

Choices and trade-offs:

  • Date and place filters before the semantic search: a search by meaning cannot tell "this weekend" from "next month", and it can miss an exact town name.
  • A light re-ranking on the question's words rather than a full hybrid search: it brings exact titles and venue names up without a second index to maintain.
  • A flat FAISS index does exact search with nothing to tune. At about 6,000 vectors that is enough; approximate indexes (IVF, HNSW) pay off at millions of vectors.
  • FAISS on disk rather than a hosted vector database: free, no extra service to run, and rebuilt in about a minute and a half.
  • Low temperature, because factual and stable answers matter more than style here.

Next steps

  • Put the API online with the weekly refresh, then follow the real questions: cost, latency, refusals.
  • A full hybrid search (BM25 next to the embeddings) for event titles and venue names.
  • Grow the test set to 50 questions or more, and use a judge from another model family.
  • Conversation memory, so a visitor can ask "and on Sunday?" after a first answer.

Code and notebooks

Portfolio assistant AI

Answers are written by an AI from the content of this site. They can be wrong: check the sources it links. Questions are kept 90 days to improve the assistant, without your IP address. How it works