Skip to content

Commit 797e901

Browse files
committed
Revert "feat(dotAI): Dot AI LangChain4J - Custom UI for provider config (#35445)"
This reverts commit 4c55a47.
1 parent c2b7ff5 commit 797e901

18 files changed

Lines changed: 165 additions & 1211 deletions

File tree

core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail-resolver.service.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail.component.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

core-web/apps/dotcms-ui/src/app/portlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail.component.ts

Lines changed: 0 additions & 157 deletions
This file was deleted.

core-web/apps/dotcms-ui/src/app/portlets/dot-apps/dot-apps.routes.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Routes } from '@angular/router';
22

33
import { DotAppsService } from '@dotcms/data-access';
44

5-
import { dotAiConfigDetailResolver } from './components/dot-ai-config-detail/dot-ai-config-detail-resolver.service';
6-
import { DotAiConfigDetailComponent } from './components/dot-ai-config-detail/dot-ai-config-detail.component';
75
import { DotAppsConfigurationComponent } from './components/dot-apps-configuration/dot-apps-configuration.component';
86
import { DotAppsConfigurationDetailComponent } from './components/dot-apps-configuration-detail/dot-apps-configuration-detail.component';
97
import { DotAppsListComponent } from './dot-apps-list/dot-apps-list.component';
@@ -12,14 +10,6 @@ import { DotAppsConfigurationResolver } from './services/dot-apps-configuration-
1210
import { DotAppsListResolver } from './services/dot-apps-list-resolver/dot-apps-list-resolver.service';
1311

1412
export const dotAppsRoutes: Routes = [
15-
{
16-
component: DotAiConfigDetailComponent,
17-
path: 'dotAI/edit/:id',
18-
resolve: {
19-
data: dotAiConfigDetailResolver
20-
},
21-
providers: [DotAppsService]
22-
},
2313
{
2414
component: DotAppsConfigurationDetailComponent,
2515
path: ':appKey/create/:id',

core-web/libs/data-access/src/lib/dot-ai/dot-ai.service.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ import { catchError, map, switchMap } from 'rxjs/operators';
88
import {
99
DotCMSContentlet,
1010
AiPluginResponse,
11+
DotAICompletionsConfig,
1112
DotAIImageContent,
1213
DotAIImageOrientation,
13-
DotAIImageResponse,
14-
DotAiProviderConfig
14+
DotAIImageResponse
1515
} from '@dotcms/dotcms-models';
1616

17-
export { DotAiProviderConfig };
18-
1917
export const AI_PLUGIN_KEY = {
2018
NOT_SET: 'NOT SET'
2119
};
@@ -107,27 +105,17 @@ export class DotAiService {
107105
*/
108106
checkPluginInstallation(): Observable<boolean> {
109107
return this.#http
110-
.get<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`, {
108+
.get<DotAICompletionsConfig>(`${API_ENDPOINT}/completions/config`, {
111109
observe: 'response'
112110
})
113111
.pipe(
114-
map((res) => res.status === 200 && !!res?.body?.providerConfig),
112+
map((res) => res.status === 200 && res?.body?.apiKey !== AI_PLUGIN_KEY.NOT_SET),
115113
catchError(() => {
116114
return of(false);
117115
})
118116
);
119117
}
120118

121-
getConfig(): Observable<DotAiProviderConfig> {
122-
return this.#http.get<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`);
123-
}
124-
125-
saveConfig(json: string): Observable<DotAiProviderConfig> {
126-
return this.#http.put<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`, json, {
127-
headers
128-
});
129-
}
130-
131119
createAndPublishContentlet(aiResponse: DotAIImageResponse): Observable<DotAIImageContent> {
132120
const { response, tempFileName } = aiResponse;
133121
const contentlets: Partial<DotCMSContentlet>[] = [

core-web/libs/dotcms-models/src/lib/dot-ai.model.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ export interface DotAICompletionsConfig {
9393
textPrompt: string;
9494
}
9595

96-
export interface DotAiProviderConfig {
97-
providerConfig: string;
98-
configHost: string;
99-
}
100-
10196
export interface DotAiError {
10297
code: string;
10398
message: string;

dotCMS/src/main/java/com/dotcms/ai/app/AppConfig.java

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public class AppConfig implements Serializable {
5252
private final String listenerIndexer;
5353
private final String providerConfig;
5454
private final String providerConfigHash;
55-
private final transient JsonNode providerConfigRoot;
5655
private final Map<String, Secret> configValues;
5756

5857
public AppConfig(final String host, final Map<String, Secret> secrets) {
@@ -68,23 +67,22 @@ public AppConfig(final String host, final Map<String, Secret> secrets) {
6867

6968
if (StringUtils.isNotBlank(providerConfig)) {
7069
providerConfigHash = DigestUtils.sha256Hex(providerConfig);
71-
providerConfigRoot = parseProviderConfig(providerConfig);
70+
final JsonNode providerConfigRoot = parseProviderConfig(providerConfig);
7271
model = buildModelFromProviderConfigNode(providerConfigRoot, "chat", AIModelType.TEXT);
7372
imageModel = buildModelFromProviderConfigNode(providerConfigRoot, "image", AIModelType.IMAGE);
7473
embeddingsModel = buildModelFromProviderConfigNode(providerConfigRoot, "embeddings", AIModelType.EMBEDDINGS);
7574
} else {
7675
providerConfigHash = "no-config";
77-
providerConfigRoot = MAPPER.createObjectNode();
7876
model = AIModel.NOOP_MODEL;
7977
imageModel = AIModel.NOOP_MODEL;
8078
embeddingsModel = AIModel.NOOP_MODEL;
8179
}
8280

83-
rolePrompt = getFromSection(providerConfigRoot, "chat", "rolePrompt", AppKeys.ROLE_PROMPT.defaultValue);
84-
textPrompt = getFromSection(providerConfigRoot, "chat", "textPrompt", AppKeys.TEXT_PROMPT.defaultValue);
85-
imagePrompt = getFromSection(providerConfigRoot, "image", "imagePrompt", AppKeys.IMAGE_PROMPT.defaultValue);
86-
imageSize = getFromSection(providerConfigRoot, "image", "size", AppKeys.IMAGE_SIZE.defaultValue);
87-
listenerIndexer = getFromSection(providerConfigRoot, "embeddings", "listenerIndexer", AppKeys.LISTENER_INDEXER.defaultValue);
81+
rolePrompt = aiAppUtil.discoverSecret(secrets, AppKeys.ROLE_PROMPT);
82+
textPrompt = aiAppUtil.discoverSecret(secrets, AppKeys.TEXT_PROMPT);
83+
imagePrompt = aiAppUtil.discoverSecret(secrets, AppKeys.IMAGE_PROMPT);
84+
imageSize = aiAppUtil.discoverSecret(secrets, AppKeys.IMAGE_SIZE);
85+
listenerIndexer = aiAppUtil.discoverSecret(secrets, AppKeys.LISTENER_INDEXER);
8886

8987
configValues = secrets.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
9088

@@ -329,7 +327,7 @@ public String getProviderConfig() {
329327
}
330328

331329
/**
332-
* Returns the SHA-256 hex digest of the {@code providerConfig} JSON, or {@code "no-config"} if not set.
330+
* Returns the SHA-256 hex digest of the {@code providerConfig} JSON, or {@code null} if not set.
333331
* Computed once at construction time — safe to use as a cache key on every request.
334332
*/
335333
public String getProviderConfigHash() {
@@ -355,25 +353,6 @@ public boolean isEnabled() {
355353
return true;
356354
}
357355

358-
private static String getFromSection(final JsonNode root, final String section,
359-
final String field, final String defaultValue) {
360-
try {
361-
final JsonNode sectionNode = root.get(section);
362-
if (sectionNode == null || sectionNode.isNull()) {
363-
return defaultValue;
364-
}
365-
final JsonNode fieldNode = sectionNode.get(field);
366-
if (fieldNode == null || fieldNode.isNull()) {
367-
return defaultValue;
368-
}
369-
// Container nodes (object/array) are serialized back to a JSON string (e.g. listenerIndexer)
370-
final String value = fieldNode.isContainerNode() ? fieldNode.toString() : fieldNode.asText();
371-
return StringUtils.isNotBlank(value) ? value : defaultValue;
372-
} catch (final Exception e) {
373-
return defaultValue;
374-
}
375-
}
376-
377356
@com.google.common.annotations.VisibleForTesting
378357
static JsonNode parseProviderConfig(final String json) {
379358
try {

0 commit comments

Comments
 (0)