typesense/include/personalization_model.h
Harisaran G 4373b2b6fd
Some checks are pending
tests / test (push) Waiting to run
add: personalization model APIs (#2001)
* add: basic recommendations endpoint

* add: POST `/recommendations/models` recommendations endpoint

* add: get specific model endpoint

* add: DELETE `/recommendations/models/:id` and GET all models recommendations endpoint

* add: ONNX model upload endpoint

* add: save the file as a .tar.gz instead of ONNX

* add: verify_tar_gz function

* add: support for model upload

* add: PUT `/recommendations/model/:id` to update the model, name, collection

* refactor: recommendations -> personalization

* add: personalization tests

* add: personalization_model_manager_tests

* fix: review comments

* fix: review comments
2024-11-14 13:08:42 +05:30

27 lines
959 B
C++

#pragma once
#include <string>
#include <vector>
#include <map>
#include "embedder_manager.h"
#include <json.hpp>
class PersonalizationModel {
public:
static inline const std::map<std::string, std::vector<std::string>> valid_model_names = {
{"recommendation", {"tyrec-1"}},
{"search", {"tyrec-2"}}
};
PersonalizationModel(const std::string& model_path);
~PersonalizationModel();
static std::string get_model_subdir(const std::string& model_id);
static Option<bool> validate_model(const nlohmann::json& model_json);
static Option<bool> create_model(const std::string& model_id, const nlohmann::json& model_json, const std::string model_data);
static Option<bool> update_model(const std::string& model_id, const nlohmann::json& model_json, const std::string model_data);
static Option<bool> delete_model(const std::string& model_id);
private:
std::string model_path_;
std::string model_id_;
};