@return the rest handler
| 322 | |
| 323 | ///@return the rest handler |
| 324 | RestHandler::RestHandler(model_list& models, ModelDownloader& downloader, program_args_t& args) |
| 325 | : supported_models(models), downloader(downloader), default_model_tag(args.model_tag), current_model_tag(""), asr(args.asr), embed(args.embed), img_pre_resize(args.img_pre_resize), preemption(args.preemption){ |
| 326 | this->npu_device_inst = xrt::device(0); |
| 327 | |
| 328 | if (args.ctx_length != -1) { |
| 329 | this->ctx_length = args.ctx_length >= 512 ? args.ctx_length : 512; |
| 330 | } else { |
| 331 | this->ctx_length = -1; |
| 332 | } |
| 333 | if (args.prefill_chunk_len != -1) { |
| 334 | this->prefill_chunk_len = args.prefill_chunk_len >= 512 ? args.prefill_chunk_len : 512; |
| 335 | } |
| 336 | else { |
| 337 | this->prefill_chunk_len = -1; |
| 338 | } |
| 339 | |
| 340 | // Initialize chat bot with default model |
| 341 | #ifndef FASTFLOWLM_LINUX_LIMITED_MODELS |
| 342 | if (this->asr) { |
| 343 | std::string whisper_tag = "whisper-v3:turbo"; |
| 344 | ensure_asr_model_loaded(whisper_tag); |
| 345 | } |
| 346 | if (this->embed) { |
| 347 | std::string embed_tag = "embed-gemma:300m"; |
| 348 | ensure_embed_model_loaded(embed_tag); |
| 349 | } |
| 350 | #else |
| 351 | if (this->asr) { |
| 352 | header_print("Error", "ASR models are not supported in this build"); |
| 353 | } |
| 354 | if (this->embed) { |
| 355 | header_print("Error", "Embedding models are not supported in this build"); |
| 356 | } |
| 357 | #endif |
| 358 | |
| 359 | if (default_model_tag != "model-faker") { |
| 360 | if (!supported_models.is_model_supported(default_model_tag)) { |
| 361 | header_print("Warning", "Default model tag '" << default_model_tag << "' is not supported. Falling back to 'llama3.2:1b'."); |
| 362 | this->default_model_tag = "llama3.2:1b"; |
| 363 | } |
| 364 | if (!ensure_model_loaded(default_model_tag)) { |
| 365 | header_print("Error", "Failed to load default model: " + default_model_tag); |
| 366 | } |
| 367 | } |
| 368 | else { |
| 369 | this->current_model_tag = "model-faker"; |
| 370 | } |
| 371 | this->prompt_cache = PromptCache(); |
| 372 | } |
| 373 | |
| 374 | ///@brief RestHandler destructor |
| 375 | ///@return the rest handler |
nothing calls this directly
no test coverage detected