MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / extract_embedding

Function extract_embedding

examples/embeddings_example.cpp:50–59  ·  view source on GitHub ↗

Helper function to extract embedding as a vector of doubles

Source from the content-addressed store, hash-verified

48
49// Helper function to extract embedding as a vector of doubles
50std::vector<double> extract_embedding(const nlohmann::json& data,
51 size_t index) {
52 std::vector<double> embedding;
53 if (data.is_array() && index < data.size()) {
54 for (const auto& val : data[index]["embedding"]) {
55 embedding.push_back(val.get<double>());
56 }
57 }
58 return embedding;
59}
60
61int main() {
62 std::cout << "AI SDK C++ - Embeddings Example\n";

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected