protected Prompt buildPrompt(Query query, Result result) {
        String prompt = getPrompt(query);

        // Replace @query with the actual query
        if (prompt.contains("@query")) {
            prompt = prompt.replace("@query", query.getModel().getQueryString());
        }

        String context = lookupProperty(CONTEXT_PROPERTY, query);
        if (context == null || !context.equals("skip")) {
            if ( !prompt.contains("{context}")) {
                prompt = "{context}\n" + prompt;
            }
            prompt = prompt.replace("{context}", buildContext(result));
        }
        return StringPrompt.from(prompt);
    }
An LLM searcher that uses the RAG (Retrieval-Augmented Generation) model to generate completions.
Prompts are generated based on the search result context.
By default, the context is a concatenation of the fields of the search result hits.

@author lesters
container-search/src/main/java/ai/vespa/search/llm/RAGSearcher.java