43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#include "dal/PgDal.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
static void contract_pgdal_basic() {
|
|
kom::PgDal dal;
|
|
dal.connect("stub://memory");
|
|
auto ns = dal.ensureNamespace("tests");
|
|
static_cast<void>(ns);
|
|
|
|
kom::ItemRow item;
|
|
item.namespace_id = "tests";
|
|
item.text = std::string("example");
|
|
item.tags = {"alpha", "beta"};
|
|
item.id = dal.upsertItem(item);
|
|
|
|
kom::ChunkRow chunk;
|
|
chunk.item_id = item.id;
|
|
chunk.text = "chunk-text";
|
|
auto chunkIds = dal.upsertChunks(std::vector<kom::ChunkRow>{chunk});
|
|
if (!chunkIds.empty()) {
|
|
chunk.id = chunkIds.front();
|
|
}
|
|
|
|
kom::EmbeddingRow embedding;
|
|
embedding.chunk_id = chunk.id;
|
|
embedding.model = "stub-model";
|
|
embedding.dim = 3;
|
|
embedding.vector = {0.1f, 0.2f, 0.3f};
|
|
dal.upsertEmbeddings(std::vector<kom::EmbeddingRow>{embedding});
|
|
|
|
static_cast<void>(dal.searchText("tests", "chunk", 5));
|
|
static_cast<void>(dal.searchVector("tests", embedding.vector, 5));
|
|
static_cast<void>(dal.getItemById(item.id));
|
|
static_cast<void>(dal.hybridSearch(embedding.vector, "stub-model", "tests", "chunk", 5));
|
|
}
|
|
|
|
static const bool contract_pgdal_compiles = [] {
|
|
contract_pgdal_basic();
|
|
return true;
|
|
}();
|