liveBook · Manning

Stuffing the prompt

As explained in Spring AI in Action

Prompt stuffing is the technique of placing an entire source document or large body of reference text directly into a model prompt.

Stuffing the prompt places a source document or large reference text alongside a question, giving the model an open-book context for answering topics absent from its training. section 3.2

A Spring application implements the technique by:

  • Storing Burger Battle rules in a classpath text file. section 3.2

Answering a rules question

Asking what the Destroy card does returns an answer grounded in the supplied Burger Battle rules. The same endpoint can answer a chess question when chess rules are available.

How Spring AI in Action covers it

How deep it goes
Explains file storage, resource loading, template substitution, and API invocation, then defers large-document handling to RAG.
Examples
Uses Burger Battle rules, a Destroy card question, classpath resources, and a Spring ChatClient endpoint.
What it assumes
Assumes a prompt-generation application and teaches the reference-file, loading, and substitution steps explicitly.
What you can do after
Build it from scratch by loading game rules and injecting them into a Spring ChatClient prompt.
How it connects
Connects prompt templates and context windows with RAG, document chunks, embeddings, and vector stores.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.