From 30ad7787a1fda17e46c16d5512495b258841e268 Mon Sep 17 00:00:00 2001 From: Victor Alfaro Date: Tue, 30 Jul 2024 21:12:25 -0600 Subject: [PATCH] #29284: initial --- .../java/com/dotcms/ai/api/AIClientAPI.java | 13 +++ .../com/dotcms/ai/{app => api}/AIModels.java | 6 +- .../java/com/dotcms/ai/api/AIServices.java | 21 +++++ .../com/dotcms/ai/api/CompletionsAPI.java | 2 +- .../com/dotcms/ai/api/CompletionsAPIImpl.java | 4 +- .../com/dotcms/ai/api/EmbeddingsAPIImpl.java | 4 +- .../com/dotcms/ai/api/EmbeddingsRunner.java | 2 +- .../java/com/dotcms/ai/app/ConfigService.java | 1 + .../dotcms/ai/{app => config}/AppConfig.java | 10 ++- .../com/dotcms/ai/config/ProviderConfig.java | 39 +++++++++ .../com/dotcms/ai/listener/AIAppListener.java | 2 +- .../ai/listener/EmbeddingContentListener.java | 2 +- .../com/dotcms/ai/{app => model}/AIModel.java | 3 +- .../java/com/dotcms/ai/model/AIProvider.java | 27 ++++++ .../ai/model/request/AIJSONObjectRequest.java | 15 ++++ .../dotcms/ai/model/request/AIRequest.java | 87 +++++++++++++++++++ .../dotcms/ai/rest/CompletionsResource.java | 4 +- .../com/dotcms/ai/rest/ImageResource.java | 2 +- .../java/com/dotcms/ai/rest/TextResource.java | 2 +- .../dotcms/ai/rest/forms/CompletionsForm.java | 2 +- .../dotcms/ai/rest/forms/EmbeddingsForm.java | 3 +- .../ai/service/OpenAIChatServiceImpl.java | 2 +- .../ai/service/OpenAIImageServiceImpl.java | 2 +- .../dotcms/ai/{app => util}/AIAppUtil.java | 5 +- .../dotcms/ai/util/ContentToStringUtil.java | 2 +- .../com/dotcms/ai/util/OpenAIRequest.java | 4 +- .../com/dotcms/ai/viewtool/AIViewTool.java | 2 +- .../dotcms/ai/viewtool/CompletionsTool.java | 2 +- .../dotcms/ai/viewtool/EmbeddingsTool.java | 2 +- .../java/com/dotcms/ai/app/AIAppUtilTest.java | 2 + .../ai/service/OpenAIChatServiceImplTest.java | 4 +- .../service/OpenAIImageServiceImplTest.java | 4 +- .../src/test/java/com/dotcms/MainSuite2b.java | 2 +- .../src/test/java/com/dotcms/ai/AiTest.java | 2 +- .../dotcms/ai/{app => api}/AIModelsTest.java | 4 +- .../dotcms/ai/viewtool/AIViewToolTest.java | 2 +- .../ai/viewtool/CompletionsToolTest.java | 2 +- .../ai/viewtool/EmbeddingsToolTest.java | 4 +- 38 files changed, 259 insertions(+), 39 deletions(-) create mode 100644 dotCMS/src/main/java/com/dotcms/ai/api/AIClientAPI.java rename dotCMS/src/main/java/com/dotcms/ai/{app => api}/AIModels.java (98%) create mode 100644 dotCMS/src/main/java/com/dotcms/ai/api/AIServices.java rename dotCMS/src/main/java/com/dotcms/ai/{app => config}/AppConfig.java (97%) create mode 100644 dotCMS/src/main/java/com/dotcms/ai/config/ProviderConfig.java rename dotCMS/src/main/java/com/dotcms/ai/{app => model}/AIModel.java (98%) create mode 100644 dotCMS/src/main/java/com/dotcms/ai/model/AIProvider.java create mode 100644 dotCMS/src/main/java/com/dotcms/ai/model/request/AIJSONObjectRequest.java create mode 100644 dotCMS/src/main/java/com/dotcms/ai/model/request/AIRequest.java rename dotCMS/src/main/java/com/dotcms/ai/{app => util}/AIAppUtil.java (98%) rename dotcms-integration/src/test/java/com/dotcms/ai/{app => api}/AIModelsTest.java (98%) diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/AIClientAPI.java b/dotCMS/src/main/java/com/dotcms/ai/api/AIClientAPI.java new file mode 100644 index 000000000000..3529af1486bd --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/api/AIClientAPI.java @@ -0,0 +1,13 @@ +package com.dotcms.ai.api; + +import com.dotcms.ai.model.request.AIRequest; + +import java.io.OutputStream; + +public interface AIClientAPI { + + void sendRequest(final AIRequest request, final OutputStream output); + + void sendRequest(final AIRequest request); + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/app/AIModels.java b/dotCMS/src/main/java/com/dotcms/ai/api/AIModels.java similarity index 98% rename from dotCMS/src/main/java/com/dotcms/ai/app/AIModels.java rename to dotCMS/src/main/java/com/dotcms/ai/api/AIModels.java index 0773d0de5711..856f7b63f6a7 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/app/AIModels.java +++ b/dotCMS/src/main/java/com/dotcms/ai/api/AIModels.java @@ -1,5 +1,9 @@ -package com.dotcms.ai.app; +package com.dotcms.ai.api; +import com.dotcms.ai.app.AIModelType; +import com.dotcms.ai.config.AppConfig; +import com.dotcms.ai.app.ConfigService; +import com.dotcms.ai.model.AIModel; import com.dotcms.ai.model.OpenAIModel; import com.dotcms.ai.model.OpenAIModels; import com.dotcms.http.CircuitBreakerUrl; diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/AIServices.java b/dotCMS/src/main/java/com/dotcms/ai/api/AIServices.java new file mode 100644 index 000000000000..ba5dd7203773 --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/api/AIServices.java @@ -0,0 +1,21 @@ +package com.dotcms.ai.api; + +import com.dotcms.ai.model.AIProvider; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +public class AIServices { + + private final ConcurrentMap> clients = new ConcurrentHashMap(); + + public List getProviders() { + return List.of(); + } + + public List getClients(final List providers) { + return List.of(); + } + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPI.java b/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPI.java index 244850408959..02d5571f97a4 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPI.java +++ b/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPI.java @@ -1,6 +1,6 @@ package com.dotcms.ai.api; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.rest.forms.CompletionsForm; import com.dotmarketing.util.json.JSONObject; import io.vavr.Lazy; diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPIImpl.java b/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPIImpl.java index f52f874142c1..2ab89c84d443 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPIImpl.java @@ -1,8 +1,8 @@ package com.dotcms.ai.api; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AIModel; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.model.AIModel; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.db.EmbeddingsDTO; diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsAPIImpl.java b/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsAPIImpl.java index 78d3e618c149..2af93f625c9f 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsAPIImpl.java @@ -1,7 +1,7 @@ package com.dotcms.ai.api; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.db.EmbeddingsDTO; @@ -54,7 +54,7 @@ import java.util.Optional; import java.util.stream.Collectors; -import static com.dotcms.ai.app.AppConfig.debugLogger; +import static com.dotcms.ai.config.AppConfig.debugLogger; import static com.liferay.util.StringPool.BLANK; /** diff --git a/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsRunner.java b/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsRunner.java index 6f352c67ccd4..f543357a44f9 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsRunner.java +++ b/dotCMS/src/main/java/com/dotcms/ai/api/EmbeddingsRunner.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.Locale; -import static com.dotcms.ai.app.AppConfig.debugLogger; +import static com.dotcms.ai.config.AppConfig.debugLogger; import static com.liferay.util.StringPool.SPACE; /** diff --git a/dotCMS/src/main/java/com/dotcms/ai/app/ConfigService.java b/dotCMS/src/main/java/com/dotcms/ai/app/ConfigService.java index ca1e9d7eb91c..7c47dc0f22ba 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/app/ConfigService.java +++ b/dotCMS/src/main/java/com/dotcms/ai/app/ConfigService.java @@ -1,5 +1,6 @@ package com.dotcms.ai.app; +import com.dotcms.ai.config.AppConfig; import com.dotcms.api.web.HttpServletRequestThreadLocal; import com.dotcms.security.apps.AppSecrets; import com.dotmarketing.beans.Host; diff --git a/dotCMS/src/main/java/com/dotcms/ai/app/AppConfig.java b/dotCMS/src/main/java/com/dotcms/ai/config/AppConfig.java similarity index 97% rename from dotCMS/src/main/java/com/dotcms/ai/app/AppConfig.java rename to dotCMS/src/main/java/com/dotcms/ai/config/AppConfig.java index d3a161daa746..49542fc8c036 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/app/AppConfig.java +++ b/dotCMS/src/main/java/com/dotcms/ai/config/AppConfig.java @@ -1,5 +1,11 @@ -package com.dotcms.ai.app; - +package com.dotcms.ai.config; + +import com.dotcms.ai.api.AIModels; +import com.dotcms.ai.app.AIModelType; +import com.dotcms.ai.app.AppKeys; +import com.dotcms.ai.app.ConfigService; +import com.dotcms.ai.model.AIModel; +import com.dotcms.ai.util.AIAppUtil; import com.dotcms.security.apps.Secret; import com.dotmarketing.exception.DotRuntimeException; import com.dotmarketing.util.Config; diff --git a/dotCMS/src/main/java/com/dotcms/ai/config/ProviderConfig.java b/dotCMS/src/main/java/com/dotcms/ai/config/ProviderConfig.java new file mode 100644 index 000000000000..c0f8d8cf3506 --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/config/ProviderConfig.java @@ -0,0 +1,39 @@ +package com.dotcms.ai.config; + +import com.dotcms.ai.model.AIProvider; + +import java.util.Objects; + +public class ProviderConfig { + + private final AIProvider provider; + + public ProviderConfig(final AIProvider provider) { + this.provider = provider; + } + + public AIProvider getProvider() { + return provider; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ProviderConfig that = (ProviderConfig) o; + return provider == that.provider; + } + + @Override + public int hashCode() { + return Objects.hashCode(provider); + } + + @Override + public String toString() { + return "ProviderConfig{" + + "provider=" + provider + + '}'; + } + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/listener/AIAppListener.java b/dotCMS/src/main/java/com/dotcms/ai/listener/AIAppListener.java index 226be03607e8..8ad1ba2d587e 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/listener/AIAppListener.java +++ b/dotCMS/src/main/java/com/dotcms/ai/listener/AIAppListener.java @@ -1,6 +1,6 @@ package com.dotcms.ai.listener; -import com.dotcms.ai.app.AIModels; +import com.dotcms.ai.api.AIModels; import com.dotcms.ai.app.AppKeys; import com.dotcms.security.apps.AppSecretSavedEvent; import com.dotcms.system.event.local.model.EventSubscriber; diff --git a/dotCMS/src/main/java/com/dotcms/ai/listener/EmbeddingContentListener.java b/dotCMS/src/main/java/com/dotcms/ai/listener/EmbeddingContentListener.java index 24dbbf1072f6..8493803e5596 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/listener/EmbeddingContentListener.java +++ b/dotCMS/src/main/java/com/dotcms/ai/listener/EmbeddingContentListener.java @@ -1,7 +1,7 @@ package com.dotcms.ai.listener; import com.dotcms.ai.api.EmbeddingsAPI; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.db.EmbeddingsDTO; diff --git a/dotCMS/src/main/java/com/dotcms/ai/app/AIModel.java b/dotCMS/src/main/java/com/dotcms/ai/model/AIModel.java similarity index 98% rename from dotCMS/src/main/java/com/dotcms/ai/app/AIModel.java rename to dotCMS/src/main/java/com/dotcms/ai/model/AIModel.java index 88b3ef6d58df..acdd579695bf 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/app/AIModel.java +++ b/dotCMS/src/main/java/com/dotcms/ai/model/AIModel.java @@ -1,5 +1,6 @@ -package com.dotcms.ai.app; +package com.dotcms.ai.model; +import com.dotcms.ai.app.AIModelType; import com.dotcms.util.DotPreconditions; import com.dotmarketing.util.Logger; diff --git a/dotCMS/src/main/java/com/dotcms/ai/model/AIProvider.java b/dotCMS/src/main/java/com/dotcms/ai/model/AIProvider.java new file mode 100644 index 000000000000..dcf917081ebe --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/model/AIProvider.java @@ -0,0 +1,27 @@ +package com.dotcms.ai.model; + +import com.dotmarketing.util.Config; + +public enum AIProvider { + + OPEN_AI("OpenAI"), + AMAZON_BEDROCK("Bedrock"), + GOOGLE_GEMINI("Gemini"),; + + private final String provider; + private final boolean enabled; + + AIProvider(final String provider) { + this.provider = provider; + enabled = Config.getBooleanProperty("AI_PROVIDER_" + provider.toUpperCase() + "_ENABLED", false); + } + + public String getProvider() { + return provider; + } + + public boolean isEnabled() { + return enabled; + } + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/model/request/AIJSONObjectRequest.java b/dotCMS/src/main/java/com/dotcms/ai/model/request/AIJSONObjectRequest.java new file mode 100644 index 000000000000..1436fedbf631 --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/model/request/AIJSONObjectRequest.java @@ -0,0 +1,15 @@ +package com.dotcms.ai.model.request; + +import com.dotcms.ai.config.AppConfig; +import com.dotmarketing.util.json.JSONObject; + +public class AIJSONObjectRequest extends AIRequest { + + public AIJSONObjectRequest(final String url, + final String method, + final AppConfig appConfig, + final JSONObject payload) { + super(url, method, appConfig, payload); + } + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/model/request/AIRequest.java b/dotCMS/src/main/java/com/dotcms/ai/model/request/AIRequest.java new file mode 100644 index 000000000000..d636a35819e5 --- /dev/null +++ b/dotCMS/src/main/java/com/dotcms/ai/model/request/AIRequest.java @@ -0,0 +1,87 @@ +package com.dotcms.ai.model.request; + +import com.dotcms.ai.config.AppConfig; + +import java.io.Serializable; + +public class AIRequest { + + private final String url; + private final String method; + private final AppConfig appConfig; + private final T payload; + + AIRequest(final String url, + final String method, + final AppConfig appConfig, + final T payload) { + this.url = url; + this.method = method; + this.appConfig = appConfig; + this.payload = payload; + } + + public String getUrl() { + return url; + } + + public String getMethod() { + return method; + } + + public AppConfig getAppConfig() { + return appConfig; + } + + public T getPayload() { + return payload; + } + + @Override + public String toString() { + return "AIRequest{" + + "url='" + url + '\'' + + ", method='" + method + '\'' + + ", appConfig=" + appConfig + + ", payload=" + payload + + '}'; + } + + static Builder builder() { + return new Builder<>(); + } + + private static class Builder { + + private String url; + private String method; + private AppConfig appConfig; + private T payload; + + public Builder url(final String url) { + this.url = url; + return this; + } + + public Builder method(final String method) { + this.method = method; + return this; + } + + public Builder appConfig(final AppConfig appConfig) { + this.appConfig = appConfig; + return this; + } + + public Builder payload(final T payload) { + this.payload = payload; + return this; + } + + public AIRequest build() { + return new AIRequest(url, method, appConfig, payload); + } + + } + +} diff --git a/dotCMS/src/main/java/com/dotcms/ai/rest/CompletionsResource.java b/dotCMS/src/main/java/com/dotcms/ai/rest/CompletionsResource.java index d56f4857870f..55a963e714ce 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/rest/CompletionsResource.java +++ b/dotCMS/src/main/java/com/dotcms/ai/rest/CompletionsResource.java @@ -2,8 +2,8 @@ import com.dotcms.ai.AiKeys; import com.dotcms.ai.api.CompletionsAPI; -import com.dotcms.ai.app.AIModels; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.api.AIModels; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.rest.forms.CompletionsForm; diff --git a/dotCMS/src/main/java/com/dotcms/ai/rest/ImageResource.java b/dotCMS/src/main/java/com/dotcms/ai/rest/ImageResource.java index 21903b41e291..c01e6b295391 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/rest/ImageResource.java +++ b/dotCMS/src/main/java/com/dotcms/ai/rest/ImageResource.java @@ -2,7 +2,7 @@ import com.dotcms.ai.AiKeys; import com.dotcms.ai.Marshaller; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.model.AIImageRequestDTO; import com.dotcms.ai.service.OpenAIImageService; diff --git a/dotCMS/src/main/java/com/dotcms/ai/rest/TextResource.java b/dotCMS/src/main/java/com/dotcms/ai/rest/TextResource.java index 28b21c5dfef8..eb9786d9a943 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/rest/TextResource.java +++ b/dotCMS/src/main/java/com/dotcms/ai/rest/TextResource.java @@ -2,7 +2,7 @@ import com.dotcms.ai.AiKeys; import com.dotcms.ai.api.CompletionsAPI; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.rest.forms.CompletionsForm; import com.dotcms.rest.WebResource; diff --git a/dotCMS/src/main/java/com/dotcms/ai/rest/forms/CompletionsForm.java b/dotCMS/src/main/java/com/dotcms/ai/rest/forms/CompletionsForm.java index a6bbbbeeec81..e9c9fbe41110 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/rest/forms/CompletionsForm.java +++ b/dotCMS/src/main/java/com/dotcms/ai/rest/forms/CompletionsForm.java @@ -1,6 +1,6 @@ package com.dotcms.ai.rest.forms; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotmarketing.business.APILocator; diff --git a/dotCMS/src/main/java/com/dotcms/ai/rest/forms/EmbeddingsForm.java b/dotCMS/src/main/java/com/dotcms/ai/rest/forms/EmbeddingsForm.java index 61815b1307eb..8d3ef553808a 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/rest/forms/EmbeddingsForm.java +++ b/dotCMS/src/main/java/com/dotcms/ai/rest/forms/EmbeddingsForm.java @@ -1,7 +1,6 @@ package com.dotcms.ai.rest.forms; -import com.dotcms.ai.app.AppConfig; -import com.dotcms.ai.app.AppKeys; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.ConfigService; import com.dotmarketing.business.APILocator; import com.dotmarketing.util.UtilMethods; diff --git a/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIChatServiceImpl.java b/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIChatServiceImpl.java index 08edb4d5d691..04588f1b62a8 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIChatServiceImpl.java +++ b/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIChatServiceImpl.java @@ -1,7 +1,7 @@ package com.dotcms.ai.service; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.util.OpenAIRequest; import com.dotmarketing.util.UtilMethods; diff --git a/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIImageServiceImpl.java b/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIImageServiceImpl.java index 57b571dc140b..aa4beea14b68 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIImageServiceImpl.java +++ b/dotCMS/src/main/java/com/dotcms/ai/service/OpenAIImageServiceImpl.java @@ -1,7 +1,7 @@ package com.dotcms.ai.service; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.model.AIImageRequestDTO; import com.dotcms.ai.util.OpenAIRequest; import com.dotcms.ai.util.OpenAiRequestUtil; diff --git a/dotCMS/src/main/java/com/dotcms/ai/app/AIAppUtil.java b/dotCMS/src/main/java/com/dotcms/ai/util/AIAppUtil.java similarity index 98% rename from dotCMS/src/main/java/com/dotcms/ai/app/AIAppUtil.java rename to dotCMS/src/main/java/com/dotcms/ai/util/AIAppUtil.java index 6feaaf24afba..466d1bcdaf2c 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/app/AIAppUtil.java +++ b/dotCMS/src/main/java/com/dotcms/ai/util/AIAppUtil.java @@ -1,5 +1,8 @@ -package com.dotcms.ai.app; +package com.dotcms.ai.util; +import com.dotcms.ai.app.AIModelType; +import com.dotcms.ai.app.AppKeys; +import com.dotcms.ai.model.AIModel; import com.dotcms.security.apps.AppsUtil; import com.dotcms.security.apps.Secret; import com.dotmarketing.util.UtilMethods; diff --git a/dotCMS/src/main/java/com/dotcms/ai/util/ContentToStringUtil.java b/dotCMS/src/main/java/com/dotcms/ai/util/ContentToStringUtil.java index 380f64122769..40d932219d3f 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/util/ContentToStringUtil.java +++ b/dotCMS/src/main/java/com/dotcms/ai/util/ContentToStringUtil.java @@ -40,7 +40,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import static com.dotcms.ai.app.AppConfig.debugLogger; +import static com.dotcms.ai.config.AppConfig.debugLogger; import static com.liferay.util.StringPool.BLANK; import static com.liferay.util.StringPool.SPACE; diff --git a/dotCMS/src/main/java/com/dotcms/ai/util/OpenAIRequest.java b/dotCMS/src/main/java/com/dotcms/ai/util/OpenAIRequest.java index e851c9b8f871..924229fba65a 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/util/OpenAIRequest.java +++ b/dotCMS/src/main/java/com/dotcms/ai/util/OpenAIRequest.java @@ -1,8 +1,8 @@ package com.dotcms.ai.util; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AIModel; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.model.AIModel; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotmarketing.exception.DotRuntimeException; diff --git a/dotCMS/src/main/java/com/dotcms/ai/viewtool/AIViewTool.java b/dotCMS/src/main/java/com/dotcms/ai/viewtool/AIViewTool.java index a33483840625..bc9ebd8eecbd 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/viewtool/AIViewTool.java +++ b/dotCMS/src/main/java/com/dotcms/ai/viewtool/AIViewTool.java @@ -1,7 +1,7 @@ package com.dotcms.ai.viewtool; import com.dotcms.ai.AiKeys; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.service.OpenAIChatService; import com.dotcms.ai.service.OpenAIChatServiceImpl; diff --git a/dotCMS/src/main/java/com/dotcms/ai/viewtool/CompletionsTool.java b/dotCMS/src/main/java/com/dotcms/ai/viewtool/CompletionsTool.java index 03f73a37a8ec..e39953a84cf9 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/viewtool/CompletionsTool.java +++ b/dotCMS/src/main/java/com/dotcms/ai/viewtool/CompletionsTool.java @@ -1,7 +1,7 @@ package com.dotcms.ai.viewtool; import com.dotcms.ai.api.CompletionsAPI; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.rest.forms.CompletionsForm; diff --git a/dotCMS/src/main/java/com/dotcms/ai/viewtool/EmbeddingsTool.java b/dotCMS/src/main/java/com/dotcms/ai/viewtool/EmbeddingsTool.java index 4411ca1cd0fd..1a17d8bf184a 100644 --- a/dotCMS/src/main/java/com/dotcms/ai/viewtool/EmbeddingsTool.java +++ b/dotCMS/src/main/java/com/dotcms/ai/viewtool/EmbeddingsTool.java @@ -1,7 +1,7 @@ package com.dotcms.ai.viewtool; import com.dotcms.ai.api.EmbeddingsAPI; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.ConfigService; import com.dotcms.ai.util.EncodingUtil; import com.dotmarketing.beans.Host; diff --git a/dotCMS/src/test/java/com/dotcms/ai/app/AIAppUtilTest.java b/dotCMS/src/test/java/com/dotcms/ai/app/AIAppUtilTest.java index 0d7ce095668a..e2b867b5866d 100644 --- a/dotCMS/src/test/java/com/dotcms/ai/app/AIAppUtilTest.java +++ b/dotCMS/src/test/java/com/dotcms/ai/app/AIAppUtilTest.java @@ -1,5 +1,7 @@ package com.dotcms.ai.app; +import com.dotcms.ai.model.AIModel; +import com.dotcms.ai.util.AIAppUtil; import com.dotcms.security.apps.Secret; import org.junit.Before; import org.junit.Test; diff --git a/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIChatServiceImplTest.java b/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIChatServiceImplTest.java index e110608dbb2c..9b6ae43d3ef0 100644 --- a/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIChatServiceImplTest.java +++ b/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIChatServiceImplTest.java @@ -1,8 +1,8 @@ package com.dotcms.ai.service; -import com.dotcms.ai.app.AIModel; +import com.dotcms.ai.model.AIModel; import com.dotcms.ai.app.AIModelType; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotmarketing.util.json.JSONObject; import org.junit.Before; diff --git a/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIImageServiceImplTest.java b/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIImageServiceImplTest.java index 1338b3110c74..a19706ce4b05 100644 --- a/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIImageServiceImplTest.java +++ b/dotCMS/src/test/java/com/dotcms/ai/service/OpenAIImageServiceImplTest.java @@ -1,8 +1,8 @@ package com.dotcms.ai.service; -import com.dotcms.ai.app.AIModel; +import com.dotcms.ai.model.AIModel; import com.dotcms.ai.app.AIModelType; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.model.AIImageRequestDTO; import com.dotcms.ai.util.StopWordsUtil; import com.dotcms.rest.api.v1.temp.DotTempFile; diff --git a/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java b/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java index 86304a1c8d95..01fde453590e 100644 --- a/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java +++ b/dotcms-integration/src/test/java/com/dotcms/MainSuite2b.java @@ -1,6 +1,6 @@ package com.dotcms; -import com.dotcms.ai.app.AIModelsTest; +import com.dotcms.ai.api.AIModelsTest; import com.dotcms.ai.listener.EmbeddingContentListenerTest; import com.dotcms.ai.viewtool.AIViewToolTest; import com.dotcms.ai.viewtool.CompletionsToolTest; diff --git a/dotcms-integration/src/test/java/com/dotcms/ai/AiTest.java b/dotcms-integration/src/test/java/com/dotcms/ai/AiTest.java index fb529a7dc30f..3f27f1de6f79 100644 --- a/dotcms-integration/src/test/java/com/dotcms/ai/AiTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/ai/AiTest.java @@ -1,6 +1,6 @@ package com.dotcms.ai; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.security.apps.Secret; import com.dotcms.security.apps.Type; diff --git a/dotcms-integration/src/test/java/com/dotcms/ai/app/AIModelsTest.java b/dotcms-integration/src/test/java/com/dotcms/ai/api/AIModelsTest.java similarity index 98% rename from dotcms-integration/src/test/java/com/dotcms/ai/app/AIModelsTest.java rename to dotcms-integration/src/test/java/com/dotcms/ai/api/AIModelsTest.java index deba9567ca88..82c5c44b063f 100644 --- a/dotcms-integration/src/test/java/com/dotcms/ai/app/AIModelsTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/ai/api/AIModelsTest.java @@ -1,6 +1,8 @@ -package com.dotcms.ai.app; +package com.dotcms.ai.api; import com.dotcms.ai.AiTest; +import com.dotcms.ai.app.AIModelType; +import com.dotcms.ai.model.AIModel; import com.dotcms.datagen.SiteDataGen; import com.dotcms.util.IntegrationTestInitService; import com.dotcms.util.network.IPUtils; diff --git a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/AIViewToolTest.java b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/AIViewToolTest.java index 0071d755f616..989975c77d1c 100644 --- a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/AIViewToolTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/AIViewToolTest.java @@ -1,7 +1,7 @@ package com.dotcms.ai.viewtool; import com.dotcms.ai.AiTest; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.datagen.UserDataGen; import com.dotcms.util.IntegrationTestInitService; import com.dotcms.util.network.IPUtils; diff --git a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/CompletionsToolTest.java b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/CompletionsToolTest.java index a8769c973d5d..87c955f8f4b2 100644 --- a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/CompletionsToolTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/CompletionsToolTest.java @@ -1,7 +1,7 @@ package com.dotcms.ai.viewtool; import com.dotcms.ai.AiTest; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.ai.app.AppKeys; import com.dotcms.datagen.EmbeddingsDTODataGen; import com.dotcms.datagen.SiteDataGen; diff --git a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/EmbeddingsToolTest.java b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/EmbeddingsToolTest.java index 22e352b60a38..fc657456f125 100644 --- a/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/EmbeddingsToolTest.java +++ b/dotcms-integration/src/test/java/com/dotcms/ai/viewtool/EmbeddingsToolTest.java @@ -1,8 +1,8 @@ package com.dotcms.ai.viewtool; -import com.dotcms.ai.app.AIModel; +import com.dotcms.ai.model.AIModel; import com.dotcms.ai.app.AIModelType; -import com.dotcms.ai.app.AppConfig; +import com.dotcms.ai.config.AppConfig; import com.dotcms.datagen.EmbeddingsDTODataGen; import com.dotcms.datagen.SiteDataGen; import com.dotcms.util.IntegrationTestInitService;