AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 15, 2026, 10:00 JST

ahic shows a simple RAG build on Gemini API and Python

ahic shows a simple RAG build on Gemini API and Python

3 Key Points

  1. What happened

    ahic published a step-by-step guide to a simple RAG (retrieval-augmented generation) system that concatenates all .txt files in a 'documents' folder and feeds them to Gemini's 'gemini-pro' model for Q&A.

  2. Why it matters

    prompts telling the model to answer only from the documents and to reply 'the document does not contain this' otherwise curb off-document answers, letting teams automate routine internal Q&A without a vector database.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The guide's design deliberately skips the machinery of a full RAG pipeline. Instead of embedding documents into vectors and retrieving relevant chunks, it simply concatenates every .txt file in a 'documents' folder into one large context and hands it to the model with strict instructions. This trades scalability for setup speed — no indexing, no vector database — which is why the author positions it as a 'simple version' suited to shorter collections.

The two examples the author ships with illustrate the intended use: an internal guideline covering leave requests, expense deadlines, remote-work limits and hiring questions, and a project memo listing the development phase end date, key customers, and the next regular meeting. Questions like how many days ahead a leave request is needed, or when Project A's next meeting is, are answered straight from those files, while a question about salaries is refused because it isn't covered.

The author also flags where this breaks down. The Gemini API caps how many tokens can be processed at once, so very long or numerous documents can trigger errors once everything is concatenated. The suggested path forward is chunking documents, embedding them, and retrieving only the most relevant chunks — the standard full RAG approach this simple version intentionally avoids.

FAQ
What do I need to run this system?
Python 3.9 or higher, the google-generativeai and python-dotenv libraries, and a Gemini API key from Google AI Studio stored in a .env file.
What happens if I ask something not in the documents?
The prompt instructs the model to reply 'the document does not contain this' and add no other information, so off-document questions get that response.
What are the limits of this simple version?
It concatenates all files into one prompt, so long or numerous documents can hit the Gemini API's token limit; the author suggests chunking and vector search as future extensions.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleWordCraft, a Rust-built open-source Word alternative, hits v0.6.1