-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da61861
commit c3c6717
Showing
38 changed files
with
259 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} |
6 changes: 5 additions & 1 deletion
6
...main/java/com/dotcms/ai/app/AIModels.java → ...main/java/com/dotcms/ai/api/AIModels.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AIProvider, List<AIClientAPI>> clients = new ConcurrentHashMap(); | ||
|
||
public List<AIProvider> getProviders() { | ||
return List.of(); | ||
} | ||
|
||
public List<AIClientAPI> getClients(final List<AIProvider> providers) { | ||
return List.of(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
dotCMS/src/main/java/com/dotcms/ai/api/CompletionsAPIImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
...ain/java/com/dotcms/ai/app/AppConfig.java → .../java/com/dotcms/ai/config/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
dotCMS/src/main/java/com/dotcms/ai/config/ProviderConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 + | ||
'}'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotCMS/src/main/java/com/dotcms/ai/listener/EmbeddingContentListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../main/java/com/dotcms/ai/app/AIModel.java → ...ain/java/com/dotcms/ai/model/AIModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
dotCMS/src/main/java/com/dotcms/ai/model/request/AIJSONObjectRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<JSONObject> { | ||
|
||
public AIJSONObjectRequest(final String url, | ||
final String method, | ||
final AppConfig appConfig, | ||
final JSONObject payload) { | ||
super(url, method, appConfig, payload); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
dotCMS/src/main/java/com/dotcms/ai/model/request/AIRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.dotcms.ai.model.request; | ||
|
||
import com.dotcms.ai.config.AppConfig; | ||
|
||
import java.io.Serializable; | ||
|
||
public class AIRequest<T extends Serializable> { | ||
|
||
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 <T extends Serializable> Builder<T> builder() { | ||
return new Builder<>(); | ||
} | ||
|
||
private static class Builder<T extends Serializable> { | ||
|
||
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); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotCMS/src/main/java/com/dotcms/ai/rest/forms/CompletionsForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
dotCMS/src/main/java/com/dotcms/ai/rest/forms/EmbeddingsForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotCMS/src/main/java/com/dotcms/ai/service/OpenAIChatServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dotCMS/src/main/java/com/dotcms/ai/service/OpenAIImageServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...ain/java/com/dotcms/ai/app/AIAppUtil.java → ...in/java/com/dotcms/ai/util/AIAppUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.