Skip to content

Commit

Permalink
Added vector database collection management functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
FuexFollets committed Feb 8, 2024
1 parent ed5f303 commit 2429612
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/lexocraft/llm/text_completion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,35 @@ namespace lc {
context_memory = Eigen::VectorXf::Zero(context_memory_size);
}

TextCompleter::VectorDatabasePointerCollection_t
TextCompleter::get_vector_database_pointers() const {
return {
.vector_database = vector_database,
.alphanumeric_vector_subdatabase = alphanumeric_vector_subdatabase,
.digit_vector_subdatabase = digit_vector_subdatabase,
.homogeneous_vector_subdatabase = homogeneous_vector_subdatabase,
.symbol_vector_subdatabase = symbol_vector_subdatabase,
.lowercase_alphanumeric_vector_subdatabase = lowercase_alphanumeric_vector_subdatabase,
.lowercase_homogeneous_vector_subdatabase = lowercase_homogeneous_vector_subdatabase,
};
}

TextCompleter& TextCompleter::assign_vector_database_pointers(
const VectorDatabasePointerCollection_t& vector_database_collection) {
vector_database = vector_database_collection.vector_database;
alphanumeric_vector_subdatabase =
vector_database_collection.alphanumeric_vector_subdatabase;
digit_vector_subdatabase = vector_database_collection.digit_vector_subdatabase;
homogeneous_vector_subdatabase = vector_database_collection.homogeneous_vector_subdatabase;
symbol_vector_subdatabase = vector_database_collection.symbol_vector_subdatabase;
lowercase_alphanumeric_vector_subdatabase =
vector_database_collection.lowercase_alphanumeric_vector_subdatabase;
lowercase_homogeneous_vector_subdatabase =
vector_database_collection.lowercase_homogeneous_vector_subdatabase;

return *this;
}

float TextCompleter::flesch_kincaid_level(const std::string& text) {
std::vector<std::string> words;
std::vector<std::string> sentences;
Expand Down
14 changes: 14 additions & 0 deletions src/lexocraft/llm/text_completion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ namespace lc {
std::shared_ptr<VectorDatabase> lowercase_alphanumeric_vector_subdatabase;
std::shared_ptr<VectorDatabase> lowercase_homogeneous_vector_subdatabase;

struct VectorDatabasePointerCollection_t {
std::shared_ptr<VectorDatabase> vector_database;
std::shared_ptr<VectorDatabase> alphanumeric_vector_subdatabase;
std::shared_ptr<VectorDatabase> digit_vector_subdatabase;
std::shared_ptr<VectorDatabase> homogeneous_vector_subdatabase;
std::shared_ptr<VectorDatabase> symbol_vector_subdatabase;

std::shared_ptr<VectorDatabase> lowercase_alphanumeric_vector_subdatabase;
std::shared_ptr<VectorDatabase> lowercase_homogeneous_vector_subdatabase;
};

[[nodiscard]] VectorDatabasePointerCollection_t get_vector_database_pointers() const;
TextCompleter& assign_vector_database_pointers(const VectorDatabasePointerCollection_t& vector_database_collection);

std::array<DatabaseTypePairElement_t, 4> database_type_pairs {
{
{alphanumeric_vector_subdatabase, grammar::Token::Type::Alphanumeric},
Expand Down

0 comments on commit 2429612

Please sign in to comment.