5#ifndef FORESTHUB_RAG_TYPES_HPP
6#define FORESTHUB_RAG_TYPES_HPP
49inline std::string
FormatContext(
const std::vector<QueryResult>& results) {
50 if (results.empty()) {
53 std::string out =
"<context>\n";
54 for (
size_t i = 0; i < results.size(); ++i) {
55 out +=
"<source id=\"" + std::to_string(i + 1) +
"\">" + results[i].content +
"</source>\n";
Retrieval-augmented generation: retriever interface and query types.
std::string FormatContext(const std::vector< QueryResult > &results)
Format query results as XML context block for LLM prompt injection.
Definition types.hpp:49
Top-level namespace for the ForestHub SDK.
Request parameters for a RAG similarity query.
Definition types.hpp:18
std::string query
Search query text.
Definition types.hpp:20
std::string collection_id
ID of the collection to search.
Definition types.hpp:19
int top_k
Number of results to return.
Definition types.hpp:21
Response from a RAG query containing matching document chunks.
Definition types.hpp:33
std::vector< QueryResult > results
Matching chunks ordered by relevance.
Definition types.hpp:34
A single document chunk returned from a RAG query.
Definition types.hpp:25
double score
Similarity score (higher = more relevant).
Definition types.hpp:29
std::string content
Text content of the chunk.
Definition types.hpp:28
std::string document_id
ID of the source document.
Definition types.hpp:27
std::string chunk_id
Unique identifier of the chunk.
Definition types.hpp:26