You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/disco/example.cpp
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -79,26 +79,26 @@ int main() {
79
79
80
80
for (auto& user_id : recommender.user_ids()) {
81
81
auto factors = pgvector::Vector(*recommender.user_factors(user_id));
82
-
tx.exec("INSERT INTO users (id, factors) VALUES ($1, $2)", {user_id, factors});
82
+
tx.exec("INSERT INTO users (id, factors) VALUES ($1, $2)", pqxx::params{user_id, factors});
83
83
}
84
84
85
85
for (auto& item_id : recommender.item_ids()) {
86
86
auto factors = pgvector::Vector(*recommender.item_factors(item_id));
87
-
tx.exec("INSERT INTO movies (name, factors) VALUES ($1, $2)", {item_id, factors});
87
+
tx.exec("INSERT INTO movies (name, factors) VALUES ($1, $2)", pqxx::params{item_id, factors});
88
88
}
89
89
90
90
std::string movie = "Star Wars (1977)";
91
91
std::cout << "Item-based recommendations for " << movie << std::endl;
92
92
pqxx::result result = tx.exec("SELECT name FROM movies WHERE name != $1 ORDER BY factors <=> (SELECT factors FROM movies WHERE name = $1) LIMIT 5", pqxx::params{movie});
Copy file name to clipboardExpand all lines: examples/openai/example.cpp
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -54,14 +54,14 @@ int main() {
54
54
auto embeddings = fetch_embeddings(input, api_key);
55
55
56
56
for (size_t i = 0; i < input.size(); i++) {
57
-
tx.exec("INSERT INTO documents (content, embedding) VALUES ($1, $2)", {input[i], pgvector::Vector(embeddings[i])});
57
+
tx.exec("INSERT INTO documents (content, embedding) VALUES ($1, $2)", pqxx::params{input[i], pgvector::Vector(embeddings[i])});
58
58
}
59
59
tx.commit();
60
60
61
61
int document_id = 1;
62
-
pqxx::result result = tx.exec("SELECT content FROM documents WHERE id != $1 ORDER BY embedding <=> (SELECT embedding FROM documents WHERE id = $1) LIMIT 5", {document_id});
63
-
for (autoconst& row : result) {
64
-
std::cout << row[0].c_str() << std::endl;
62
+
pqxx::result result = tx.exec("SELECT content FROM documents WHERE id != $1 ORDER BY embedding <=> (SELECT embedding FROM documents WHERE id = $1) LIMIT 5", pqxx::params{document_id});
0 commit comments