feat: implement conditional AI runtime features based on build configuration
- Added conditional compilation for AI services and callbacks based on the YAZE_AI_RUNTIME_AVAILABLE flag. - Implemented stubs for AI service methods to return errors when the AI runtime is disabled, enhancing error handling. - Updated GeminiAIService and OllamaAIService to provide appropriate responses when AI features are not available. - Introduced a new service factory stub to create mock AI services when the runtime is disabled, improving testing capabilities.
This commit is contained in:
27
src/cli/service/ai/service_factory_stub.cc
Normal file
27
src/cli/service/ai/service_factory_stub.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef YAZE_AI_RUNTIME_AVAILABLE
|
||||
|
||||
#include "cli/service/ai/service_factory.h"
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
|
||||
namespace yaze::cli {
|
||||
|
||||
std::unique_ptr<AIService> CreateAIService() {
|
||||
return std::make_unique<MockAIService>();
|
||||
}
|
||||
|
||||
std::unique_ptr<AIService> CreateAIService(const AIServiceConfig&) {
|
||||
return std::make_unique<MockAIService>();
|
||||
}
|
||||
|
||||
absl::StatusOr<std::unique_ptr<AIService>> CreateAIServiceStrict(
|
||||
const AIServiceConfig&) {
|
||||
return absl::FailedPreconditionError(
|
||||
"AI runtime features are disabled in this build");
|
||||
}
|
||||
|
||||
} // namespace yaze::cli
|
||||
|
||||
#endif // !YAZE_AI_RUNTIME_AVAILABLE
|
||||
|
||||
Reference in New Issue
Block a user