forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.h
More file actions
64 lines (53 loc) · 1.97 KB
/
Copy pathmodels.h
File metadata and controls
64 lines (53 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <SQLiteCpp/Database.h>
#include <trantor/utils/Logger.h>
#include <string>
#include <vector>
#include "utils/result.hpp"
namespace cortex::db {
enum class ModelStatus { Remote, Downloaded, Downloadable };
struct ModelEntry {
std::string model;
std::string author_repo_id;
std::string branch_name;
std::string path_to_model_yaml;
std::string model_alias;
std::string model_format;
std::string model_source;
ModelStatus status;
std::string engine;
std::string metadata;
};
class Models {
private:
SQLite::Database& db_;
bool IsUnique(const std::vector<ModelEntry>& entries,
const std::string& model_id) const;
cpp::result<std::vector<ModelEntry>, std::string> LoadModelListNoLock() const;
std::string StatusToString(ModelStatus status) const;
ModelStatus StringToStatus(const std::string& status_str) const;
public:
cpp::result<std::vector<ModelEntry>, std::string> LoadModelList() const;
Models();
Models(SQLite::Database& db);
~Models();
cpp::result<ModelEntry, std::string> GetModelInfo(
const std::string& identifier) const;
void PrintModelInfo(const ModelEntry& entry) const;
cpp::result<bool, std::string> AddModelEntry(ModelEntry new_entry);
cpp::result<bool, std::string> UpdateModelEntry(
const std::string& identifier, const ModelEntry& updated_entry);
cpp::result<bool, std::string> DeleteModelEntry(
const std::string& identifier);
cpp::result<bool, std::string> DeleteModelEntryWithOrg(
const std::string& src);
cpp::result<bool, std::string> DeleteModelEntryWithRepo(
const std::string& src);
cpp::result<std::vector<std::string>, std::string> FindRelatedModel(
const std::string& identifier) const;
bool HasModel(const std::string& identifier) const;
cpp::result<std::vector<ModelEntry>, std::string> GetModels(
const std::string& model_src) const;
cpp::result<std::vector<ModelEntry>, std::string> GetModelSources() const;
};
} // namespace cortex::db