| #pragma once
|
|
|
| #include "common.h"
|
| #include "arg.h"
|
|
|
| #include <string>
|
| #include <vector>
|
| #include <map>
|
| #include <set>
|
|
|
|
|
|
|
|
|
|
|
| constexpr const char * COMMON_PRESET_DEFAULT_NAME = "default";
|
|
|
| struct common_preset_context;
|
|
|
| struct common_preset {
|
| std::string name;
|
|
|
|
|
| std::map<common_arg, std::string> options;
|
|
|
|
|
| std::vector<std::string> to_args(const std::string & bin_path = "") const;
|
|
|
|
|
| std::string to_ini() const;
|
|
|
|
|
|
|
|
|
| void set_option(const common_preset_context & ctx, const std::string & env, const std::string & value);
|
|
|
|
|
| void unset_option(const std::string & env);
|
|
|
|
|
| bool get_option(const std::string & env, std::string & value) const;
|
|
|
|
|
| void merge(const common_preset & other);
|
|
|
|
|
| void apply_to_params(common_params & params) const;
|
| };
|
|
|
|
|
| using common_presets = std::map<std::string, common_preset>;
|
|
|
|
|
| struct common_preset_context {
|
| common_params default_params;
|
| common_params_context ctx_params;
|
| std::map<std::string, common_arg> key_to_opt;
|
|
|
| bool filter_allowed_keys = false;
|
| std::set<std::string> allowed_keys;
|
|
|
|
|
| common_preset_context(llama_example ex, bool only_remote_allowed = false);
|
|
|
|
|
| common_presets load_from_ini(const std::string & path, common_preset & global) const;
|
|
|
|
|
| common_presets load_from_cache() const;
|
|
|
|
|
|
|
| common_presets load_from_models_dir(const std::string & models_dir) const;
|
|
|
|
|
| common_preset load_from_args(int argc, char ** argv) const;
|
|
|
|
|
|
|
| common_presets cascade(const common_presets & base, const common_presets & added) const;
|
|
|
|
|
| common_presets cascade(const common_preset & base, const common_presets & presets) const;
|
| };
|
|
|