AI4A is an AI assistant for agroforestry. It answers questions using retrieval-augmented generation (RAG) over a curated knowledge base - research from the EURAF community on Zenodo plus a catalogue of agroforestry tools, datasets, and projects. Built with Next.js.
It's already live at digitaf.eu.
AI4A uses retrieval-augmented generation (RAG): instead of answering from the model's general memory, it first finds the most relevant passages in its knowledge base, then asks Mistral to write an answer grounded in them — with citations back to the sources.
flowchart LR
Q(["Your question"]) --> E["Turn the question into<br/>a vector (HuggingFace)"]
E --> S["Search the knowledge base<br/>for the closest passages"]
KB[("Knowledge base<br/>Zenodo research + catalogue")] --> S
S --> M["Mistral writes an answer<br/>grounded in those passages"]
M --> A(["Answer + source citations"])
The knowledge base ships pre-built in public/data/, so a fresh clone works out of the box. See INTEGRATION.md for the full architecture, the embed widget, and self-hosting.
| To do this | You need |
|---|---|
| Use it — just ask questions | Open digitaf.eu |
| Embed it — add the chat widget to your site | One <script> tag (below) |
| Host your own — run your own instance | Node.js 20+ and the two API keys below |
API keys for self-hosting (bring your own: free to start, billed to your accounts):
| Key | What it's for | Get one at |
|---|---|---|
MISTRAL_API_KEY |
Chat answers | https://console.mistral.ai/ |
HUGGINGFACE_API_KEY |
Embeddings (search) | https://huggingface.co/settings/tokens |
Add the assistant to any site with a single tag:
<script src="https://digitafmagicbox.vercel.app/widget.js" defer></script>A chat button appears in the bottom-right corner. Set the title, colour, suggested questions, theme, and more via data-* attributes — see INTEGRATION.md for the full widget reference.
digitafmagicbox.vercel.appis the hosted app that serves the widget and API — use it (or your own instance's domain) in the script. digitaf.eu is the end-user site.
Running it locally is quick — clone, install, add your keys, run:
git clone <repository-url> digitaf
cd digitaf
npm install
cp .env.example .env.local # then add your two API keys (see "What you need")
npm run dev # → http://localhost:3000Open http://localhost:3000 and start asking. (Both keys matter: without MISTRAL_API_KEY the chat can't reply, and without HUGGINGFACE_API_KEY it answers from general knowledge only, since the knowledge-base search can't run.)
For production (any Node host):
npm run build && npm run startSet MISTRAL_API_KEY and HUGGINGFACE_API_KEY as environment variables in your host — don't commit .env.local. Full hosting guide: INTEGRATION.md → Hosting Your Own Instance.
Without the keys the app builds and the UI loads, but the chat won't answer —
MISTRAL_API_KEYis required for replies andHUGGINGFACE_API_KEYfor knowledge-base search. Add both before real use.
Pre-built embeddings ship in public/data, so the app works out of the box. To rebuild or refresh from live sources:
npm run build:all-embeddings # Zenodo research + catalogueRebuilding needs HUGGINGFACE_API_KEY, and the embedding model must match between build time and query time — see INTEGRATION.md → How Embeddings Work before changing anything. A GitHub Actions workflow (monthly-update.yml) can refresh the data automatically each month. For custom data sources and the API reference, see INTEGRATION.md.
MIT — see LICENSE, which covers this project's code. The knowledge base bundled in public/data/ is generated from Zenodo and catalogue sources that keep their own licenses and attribution. DigitAF is developed as part of the DigitAF initiative under the EURAF community.
Developer: Miska Nevalainen — miska.nevalainen@efi.int