ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (c) 2026 ForestHub. All rights reserved.
3// For commercial licensing, visit https://github.com/ForestHubAI/fh-sdk
4
5#ifndef FORESTHUB_RAG_TYPES_HPP
6#define FORESTHUB_RAG_TYPES_HPP
7
10
11#include <string>
12#include <vector>
13
14namespace foresthub {
15namespace rag {
16
19 std::string collection_id;
20 std::string query;
21 int top_k = 5;
22};
23
26 std::string chunk_id;
27 std::string document_id;
28 std::string content;
29 double score = 0.0;
30};
31
34 std::vector<QueryResult> results;
35};
36
49inline std::string FormatContext(const std::vector<QueryResult>& results) {
50 if (results.empty()) {
51 return "";
52 }
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";
56 }
57 out += "</context>";
58 return out;
59}
60
61} // namespace rag
62} // namespace foresthub
63
64#endif // FORESTHUB_RAG_TYPES_HPP
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