Economics AI Agent: RAG Over a Vector Database of Economic and Financial Data

An AI agent answers economics questions from a curated knowledge base, not from memory. A scheduled pipeline embeds source data into a vector database, structured figures go into tables, and every answer is grounded in retrieved data.

Economics AI Agent: RAG Over a Vector Database of Economic and Financial Data
Before
  • ×Reference data spread across spreadsheets and websites
  • ×A general chatbot answered from training data
  • ×No sources, and numbers often out of date
After
  • ✓A scheduled pipeline embeds fresh content into Pinecone
  • ✓Structured indicators stored in tables
  • ✓The agent retrieves context and exact figures before answering
  • ✓Answers come only from what was retrieved

Stack

n8nOpenAI APIOpenAI EmbeddingsPineconeFirecrawlGoogle Sheets

How It Works

1

Scheduled ingestion

The source list is read from Google Sheets and Firecrawl extracts clean content from each source.

2

Chunk and embed

Content is split into chunks and embedded with the OpenAI API.

3

Upsert to the vector database

Embeddings are upserted into Pinecone, so the knowledge base stays current without manual re-indexing.

4

Store structured figures

Indicators and time series go into tables, so numeric questions get exact values instead of approximate text.

5

Answer with RAG

The agent retrieves the relevant chunks and table rows for each question and answers from them.

Results

RAG

answers grounded in retrieved data

Scheduled

automatic re-indexing

Vector + tables

text and exact figures

The Workflows

Ingestion and embeddings

  • ✓Sources re-read and re-embedded on a schedule
  • ✓Content chunked and stored in a vector database for retrieval
  • ✓No manual re-indexing when sources change
The ingestion pipeline: content chunked, embedded with OpenAI and upserted to the vector database.
The ingestion pipeline: content chunked, embedded with OpenAI and upserted to the vector database.

Answers grounded in retrieved data

  • ✓Every answer is built from retrieved passages, not model memory
  • ✓Analysis comes with the source it was drawn from
An answer grounded in retrieved data: economic outlook for Saudi Arabia, 2018 to 2022.
An answer grounded in retrieved data: economic outlook for Saudi Arabia, 2018 to 2022.
The analysis behind the figures, with its source.
The analysis behind the figures, with its source.

Tables for exact figures

  • ✓Numeric questions answered from tables, not approximate text
  • ✓The agent can build a table on request and share a link
Asked for a table, the agent builds one and returns a link.
Asked for a table, the agent builds one and returns a link.
The workflow that creates that table in Google Sheets.
The workflow that creates that table in Google Sheets.
The generated table of economic indicators.
The generated table of economic indicators.

FAQ

What is RAG?+

Retrieval-augmented generation: the agent searches a knowledge base for relevant passages first and writes its answer from them, instead of relying on what the model remembers.

Which vector database does it use?+

Pinecone, with OpenAI embeddings, orchestrated in n8n.

How does the knowledge base stay current?+

A scheduled pipeline re-reads the sources, re-embeds changed content and upserts it to the index.

Can it give exact numbers?+

Yes. Structured indicators live in tables, so numeric questions are answered from the table rather than from text.