diff --git a/.gitignore b/.gitignore index 85df344..27c37b2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ pgvector/ snake_game/ pacman_game/ ai_videos.csv - +config.toml diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 16353a6..5d9a1b5 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,7 +4,7 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/**", - "${workspaceFolder}/liboai/include", + "${workspaceFolder}/src/liboai/include", "/usr/include/poppler/cpp" ], "defines": [], diff --git a/README.md b/README.md index 5bb5223..a931777 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,12 @@ cd mentals-ai **Configuration** +Copy the sample configuration file: + +```shell +cp config.toml.sample config.toml +``` + Place your API key in the `config.toml` file: ```bash diff --git a/config.toml b/config.toml.sample similarity index 100% rename from config.toml rename to config.toml.sample diff --git a/src/pgvector.cpp b/src/pgvector.cpp index 6a18607..92954c9 100644 --- a/src/pgvector.cpp +++ b/src/pgvector.cpp @@ -162,8 +162,12 @@ expected PgVector::write_content( ); std::string name_value = name ? *name : ""; std::string desc_value = desc ? *desc : ""; - txn.exec_params(sql, content_id, name_value, desc_value, content, - (std::ostringstream() << embedding).str()); + + std::ostringstream oss; + oss << embedding; + std::string embedding_str = oss.str(); + + txn.exec_params(sql, content_id, name_value, desc_value, content, embedding_str); unguard(); return {}; } @@ -198,7 +202,12 @@ expected PgVector::search_content( { "distance_function" , CosineDistance }, { "limit" , to_string(limit) } })); - pqxx::result res = txn.exec_params(sql, (std::ostringstream() << search_vector).str()); + + std::ostringstream oss; + oss << search_vector; + std::string search_vector_str = oss.str(); + + pqxx::result res = txn.exec_params(sql, search_vector_str); txn.commit(); json j_result = json::array(); for (auto row : res) {