| 182 | } |
| 183 | |
| 184 | RCLIHandle rcli_create(const char* config_json) { |
| 185 | auto* engine = new (std::nothrow) RCLIEngine(); |
| 186 | if (!engine) return nullptr; |
| 187 | |
| 188 | if (config_json && config_json[0]) { |
| 189 | std::string cfg(config_json); |
| 190 | std::string dir = config_get_string(cfg, "models_dir"); |
| 191 | if (!dir.empty()) engine->models_dir = dir; |
| 192 | std::string prompt = config_get_string(cfg, "system_prompt"); |
| 193 | if (!prompt.empty()) engine->config_system_prompt = prompt; |
| 194 | std::string eng = config_get_string(cfg, "engine"); |
| 195 | if (!eng.empty()) engine->config_engine_override = eng; |
| 196 | engine->config_gpu_layers = config_get_int(cfg, "gpu_layers", -1); |
| 197 | engine->config_ctx_size = config_get_int(cfg, "ctx_size", -1); |
| 198 | } |
| 199 | |
| 200 | engine->actions.register_defaults(); |
| 201 | |
| 202 | return static_cast<RCLIHandle>(engine); |
| 203 | } |
| 204 | |
| 205 | void rcli_destroy(RCLIHandle handle) { |
| 206 | if (!handle) return; |