/*
* Copyright 2024 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
#ifndef ENGINESELECTOR_H
#define ENGINESELECTOR_H
#include
#include
#include
#include "engine/aienginepluginmanager.h"
#include "services/modelconfig/modelconfigmanager.h"
class EngineSelector {
public:
EngineSelector(ai_engine::AiEnginePluginManager &aiEnginePluginManager, ModelConfigManager &modelConfigManager);
// core_ai speech
std::unique_ptr selectCoreAiSpeechEngine() const;
std::unique_ptr selectCoreAiSpeechEngine(
const std::string &modelName) const;
std::unique_ptr selectCoreAiSpeechEngine(
DeployType deployType) const;
std::unique_ptr selectCoreAiSpeechEngine(
DeployType deployType, const std::string &modelName) const;
// core_ai image-process
std::unique_ptr selectCoreAiImageProcessEngine() const;
bool isLocalCoreAiImageProcessEngineExist() const;
// core_ai text-recognition
std::unique_ptr selectTextRecognitionEngine() const;
// core_ai embedding
std::unique_ptr selectCoreAiEmbeddingEngine(
const std::string &modelName) const;
// gen_ai text-generation
std::unique_ptr selectGenAiTextGenerationEngine() const;
std::unique_ptr selectGenAiTextGenerationEngine(
const std::string &modelName) const;
std::unique_ptr selectGenAiTextGenerationEngine(
DeployType deployType) const;
std::unique_ptr selectGenAiTextGenerationEngine(
DeployType deployType, const std::string &modelName) const;
bool isLocalGenAiTextGenerationEngineExist() const;
using GenAiTextGenerationEnginePredicate =
std::function &engine)>;
std::unique_ptr selectNextPriorityGenAiTextGenerationEngine(
DeployType currentDeployType, GenAiTextGenerationEnginePredicate predicate) const;
// gen_ai image-generation
std::unique_ptr selectGenAiImageGenerationEngine() const;
std::unique_ptr selectGenAiImageGenerationEngine(
const std::string &modelName) const;
std::unique_ptr selectGenAiImageGenerationEngine(
DeployType deployType) const;
private:
std::map getCurrentModelSchedulingPriority(AiCapability capability) const;
DeployType selectModelDeployType(AiCapability capability) const;
DeployType selectNextPriorityDeployType(AiCapability capability, DeployType currentDeployType) const;
private:
ai_engine::AiEnginePluginManager &aiEnginePluginManager_;
ModelConfigManager &modelConfigManager_;
};
#endif