Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6b94e4f
feat(dotAI): consolidate config into single providerConfig JSON with …
ihoffmann-dot Apr 21, 2026
99944b6
fix(dotAI): restore original YAML description, remove redundant field…
ihoffmann-dot Apr 21, 2026
12dbb1f
fix(dotAI): set providerConfig as visible field (hidden: false)
ihoffmann-dot Apr 21, 2026
1302acd
fix(dotAI): disable allowExtraParameters to remove Custom Properties …
ihoffmann-dot Apr 21, 2026
5805599
temp: revert allowExtraParameters to true for cleanup
ihoffmann-dot Apr 21, 2026
1f1f494
feat(ai): multi-model fallback via comma-separated model field
ihoffmann-dot Apr 21, 2026
5cb58a2
refactor(ai): remove PUT config endpoint and ProviderConfigMerger
ihoffmann-dot Apr 22, 2026
d010f7f
refactor(ai): extract executeWithFallback helper in LangChain4jAIClient
ihoffmann-dot Apr 22, 2026
5c73e87
fix(postman): update AI collection for providerConfig consolidation
ihoffmann-dot Apr 22, 2026
b6321ca
fix(ai): move listenerIndexer into providerConfig in AiTest setup
ihoffmann-dot Apr 23, 2026
9985b5b
Merge branch 'main' into dot-ai-langchain-fixes
ihoffmann-dot Apr 23, 2026
74bea41
feat(ai): custom UI and PUT endpoint for dotAI provider config
ihoffmann-dot Apr 23, 2026
f7d63b9
refactor(ai): address PR review comments on LangChain4jAIClient and P…
ihoffmann-dot Apr 23, 2026
4bfd48a
feat(ai): auto-route maxTokens to max_completion_tokens for OpenAI re…
ihoffmann-dot Apr 23, 2026
b7451fa
revert(ai): keep model() as @Nullable String in ProviderConfig
ihoffmann-dot Apr 23, 2026
3711fd1
fix(ai): flush SSE chunks, cancelled flag on IOException, maxRetries …
ihoffmann-dot Apr 23, 2026
a6dae0d
fix(ai): null check in parseSection, deepCopy in injectApiKeyIntoSect…
ihoffmann-dot Apr 23, 2026
fc368f1
feat(ai): two-column UI, fix resolver, rendering bug, dotAI.yml descr…
ihoffmann-dot Apr 23, 2026
7eb1996
Merge branch 'main' into dot-ai-langchain-custom-ui
ihoffmann-dot Apr 23, 2026
43d1a65
fix(ai): immutable allModels(), fallback tests, self-import, javadoc,…
ihoffmann-dot Apr 24, 2026
cbcd812
test(ai): ProviderConfigMerger unit tests + Postman PUT config tests
ihoffmann-dot Apr 24, 2026
0ae65cd
fix(postman): use invalid credentials in Config-Unauthorized test
ihoffmann-dot Apr 24, 2026
8fb6fd3
fix(ai): address PR review issues #1-#6 #8
ihoffmann-dot Apr 24, 2026
e8ec864
fix(postman): clear JSESSIONID before unauthorized test to force 401
ihoffmann-dot Apr 24, 2026
871913e
test(postman): remove Config-Unauthorized test (Newman cookie jar lim…
ihoffmann-dot Apr 24, 2026
2169709
fix(ai): address PR review issues #1 #2 #4 #6
ihoffmann-dot Apr 24, 2026
cc99a42
refactor(ai): signals, takeUntilDestroyed, Tailwind, p-button
ihoffmann-dot Apr 24, 2026
c3cc0cf
fix(ai): sentinel guard, move DotAiProviderConfig to models, fix goTo…
ihoffmann-dot Apr 24, 2026
c6f82c1
fix(ai): replace containsMasked with containsMaskedCredential in post…
ihoffmann-dot Apr 24, 2026
1d90b9b
chore(ai): delete empty SCSS file
ihoffmann-dot Apr 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';

import { take } from 'rxjs/operators';

import { DotAppsService } from '@dotcms/data-access';
import { DotApp } from '@dotcms/dotcms-models';

const DOT_AI_APP_KEY = 'dotAI';

export const dotAiConfigDetailResolver: ResolveFn<DotApp> = (route: ActivatedRouteSnapshot) => {
const id = route.paramMap.get('id');

return inject(DotAppsService).getConfiguration(DOT_AI_APP_KEY, id).pipe(take(1));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@if (app(); as app) {
<div class="flex flex-col w-full overflow-y-auto bg-white shadow-md text-sm">
<div class="bg-white sticky top-0 z-[1]">
<dot-apps-configuration-header [app]="app" />
<div
class="border-b border-gray-300 text-black flex justify-between text-base font-semibold px-3 py-3">
<span class="inline-flex items-center">{{ app.sites?.[0]?.name }}</span>
<div class="flex gap-1">
<p-button (click)="goToApps()" [label]="'Cancel' | dm" [outlined]="true" />
<p-button (click)="onSubmit()" [label]="'Save' | dm" [loading]="saving()" />
</div>
</div>
</div>
<div class="grow overflow-y-auto">
<div class="m-4">
<div class="grid grid-cols-2 gap-4 items-start">
<div class="flex flex-col gap-2">
<h4 class="text-black text-sm font-semibold m-0">Provider Config</h4>
<textarea
pTextarea
[ngModel]="configJson()"
(ngModelChange)="configJson.set($event)"
rows="20"
class="font-mono text-xs resize-y w-full"
spellcheck="false"></textarea>
</div>
<div class="flex flex-col gap-2">
<h4 class="text-black text-sm font-semibold m-0">Example JSON</h4>
<pre
class="bg-gray-100 border border-gray-300 rounded text-gray-700 font-mono text-xs leading-relaxed m-0 overflow-auto p-3 whitespace-pre"
>{{ exampleJson }}</pre
>
</div>
</div>
</div>
</div>
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { Component, DestroyRef, OnInit, inject, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';

import { ButtonModule } from 'primeng/button';
import { TextareaModule } from 'primeng/textarea';

import { map } from 'rxjs/operators';

import {
DotAiService,
DotMessageDisplayService,
DotMessageService,
DotRouterService
} from '@dotcms/data-access';
import { DotApp, DotMessageSeverity, DotMessageType } from '@dotcms/dotcms-models';
import { DotMessagePipe } from '@dotcms/ui';

import { DotAppsConfigurationHeaderComponent } from '../dot-apps-configuration-detail/components/dot-apps-configuration-header/dot-apps-configuration-header.component';

const EXAMPLE_CONFIG = {
chat: {
provider: 'openai',
apiKey: 'sk-...',
model: 'gpt-4o',
maxTokens: 16384,
temperature: 1.0,
maxRetries: 3,
rolePrompt: 'You are dotCMSbot, an AI assistant to help content creators.',
textPrompt: 'Use Descriptive writing style.'
},
embeddings: {
provider: 'openai',
apiKey: 'sk-...',
model: 'text-embedding-ada-002',
listenerIndexer: { default: 'blog,news,webPageContent' }
},
image: {
provider: 'openai',
apiKey: 'sk-...',
model: 'dall-e-3',
size: '1792x1024',
imagePrompt: 'Use 16:9 aspect ratio.'
}
};

@Component({
selector: 'dot-ai-config-detail',
templateUrl: './dot-ai-config-detail.component.html',
host: { class: 'flex h-full p-4 bg-gray-200 shadow-md' },
imports: [
FormsModule,
ButtonModule,
TextareaModule,
DotAppsConfigurationHeaderComponent,
DotMessagePipe
]
})
export class DotAiConfigDetailComponent implements OnInit {
private route = inject(ActivatedRoute);
private dotAiService = inject(DotAiService);
private dotRouterService = inject(DotRouterService);
private dotMessageDisplayService = inject(DotMessageDisplayService);
private dotMessageService = inject(DotMessageService);
private destroyRef = inject(DestroyRef);

readonly app = signal<DotApp | null>(null);
readonly configJson = signal('');
readonly saving = signal(false);
readonly exampleJson = JSON.stringify(EXAMPLE_CONFIG, null, 2);

ngOnInit(): void {
this.route.data
.pipe(
map((x) => x?.data),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((app: DotApp) => {
this.app.set(app);
});

this.dotAiService
.getConfig()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (config) => {
if (config?.providerConfig) {
try {
this.configJson.set(
JSON.stringify(JSON.parse(config.providerConfig), null, 2)
);
} catch {
this.configJson.set(config.providerConfig);
}
}
},
error: (err) => {
const detail =
err?.error?.error ?? err?.message ?? 'Failed to load AI configuration';
this.dotMessageDisplayService.push({
life: 5000,
message: detail,
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});
}
});
}
Comment thread
zJaaal marked this conversation as resolved.

onSubmit(): void {
try {
JSON.parse(this.configJson());
} catch {
this.dotMessageDisplayService.push({
life: 5000,
message: 'Invalid JSON — please check the provider configuration',
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});

return;
}

this.saving.set(true);
this.dotAiService
.saveConfig(this.configJson())
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: () => {
this.saving.set(false);
this.dotMessageDisplayService.push({
life: 3000,
message: this.dotMessageService.get('dot.common.message.saved'),
severity: DotMessageSeverity.SUCCESS,
type: DotMessageType.SIMPLE_MESSAGE
});
},
error: (err) => {
this.saving.set(false);
const detail =
err?.error?.error ?? err?.message ?? 'Failed to save AI configuration';
this.dotMessageDisplayService.push({
life: 5000,
message: detail,
severity: DotMessageSeverity.ERROR,
type: DotMessageType.SIMPLE_MESSAGE
});
}
});
}
Comment thread
zJaaal marked this conversation as resolved.

goToApps(): void {
const key = this.app()?.key ?? 'dotAI';
this.dotRouterService.goToAppsConfiguration(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Routes } from '@angular/router';

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

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

export const dotAppsRoutes: Routes = [
{
component: DotAiConfigDetailComponent,
path: 'dotAI/edit/:id',
resolve: {
data: dotAiConfigDetailResolver
},
providers: [DotAppsService]
},
{
component: DotAppsConfigurationDetailComponent,
path: ':appKey/create/:id',
Expand Down
20 changes: 16 additions & 4 deletions core-web/libs/data-access/src/lib/dot-ai/dot-ai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { catchError, map, switchMap } from 'rxjs/operators';
import {
DotCMSContentlet,
AiPluginResponse,
DotAICompletionsConfig,
DotAIImageContent,
DotAIImageOrientation,
DotAIImageResponse
DotAIImageResponse,
DotAiProviderConfig
} from '@dotcms/dotcms-models';

export { DotAiProviderConfig };

export const AI_PLUGIN_KEY = {
NOT_SET: 'NOT SET'
};
Expand Down Expand Up @@ -105,17 +107,27 @@ export class DotAiService {
*/
checkPluginInstallation(): Observable<boolean> {
return this.#http
.get<DotAICompletionsConfig>(`${API_ENDPOINT}/completions/config`, {
.get<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`, {
observe: 'response'
})
.pipe(
map((res) => res.status === 200 && res?.body?.apiKey !== AI_PLUGIN_KEY.NOT_SET),
map((res) => res.status === 200 && !!res?.body?.providerConfig),
catchError(() => {
return of(false);
})
);
}

getConfig(): Observable<DotAiProviderConfig> {
return this.#http.get<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`);
}

saveConfig(json: string): Observable<DotAiProviderConfig> {
return this.#http.put<DotAiProviderConfig>(`${API_ENDPOINT}/completions/config`, json, {
headers
});
}

createAndPublishContentlet(aiResponse: DotAIImageResponse): Observable<DotAIImageContent> {
const { response, tempFileName } = aiResponse;
const contentlets: Partial<DotCMSContentlet>[] = [
Expand Down
5 changes: 5 additions & 0 deletions core-web/libs/dotcms-models/src/lib/dot-ai.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export interface DotAICompletionsConfig {
textPrompt: string;
}

export interface DotAiProviderConfig {
providerConfig: string;
configHost: string;
}

export interface DotAiError {
code: string;
message: string;
Expand Down
35 changes: 28 additions & 7 deletions dotCMS/src/main/java/com/dotcms/ai/app/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class AppConfig implements Serializable {
private final String listenerIndexer;
private final String providerConfig;
private final String providerConfigHash;
private final transient JsonNode providerConfigRoot;
private final Map<String, Secret> configValues;

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

if (StringUtils.isNotBlank(providerConfig)) {
providerConfigHash = DigestUtils.sha256Hex(providerConfig);
final JsonNode providerConfigRoot = parseProviderConfig(providerConfig);
providerConfigRoot = parseProviderConfig(providerConfig);
model = buildModelFromProviderConfigNode(providerConfigRoot, "chat", AIModelType.TEXT);
imageModel = buildModelFromProviderConfigNode(providerConfigRoot, "image", AIModelType.IMAGE);
embeddingsModel = buildModelFromProviderConfigNode(providerConfigRoot, "embeddings", AIModelType.EMBEDDINGS);
} else {
providerConfigHash = "no-config";
providerConfigRoot = MAPPER.createObjectNode();
model = AIModel.NOOP_MODEL;
imageModel = AIModel.NOOP_MODEL;
embeddingsModel = AIModel.NOOP_MODEL;
}

rolePrompt = aiAppUtil.discoverSecret(secrets, AppKeys.ROLE_PROMPT);
textPrompt = aiAppUtil.discoverSecret(secrets, AppKeys.TEXT_PROMPT);
imagePrompt = aiAppUtil.discoverSecret(secrets, AppKeys.IMAGE_PROMPT);
imageSize = aiAppUtil.discoverSecret(secrets, AppKeys.IMAGE_SIZE);
listenerIndexer = aiAppUtil.discoverSecret(secrets, AppKeys.LISTENER_INDEXER);
rolePrompt = getFromSection(providerConfigRoot, "chat", "rolePrompt", AppKeys.ROLE_PROMPT.defaultValue);
textPrompt = getFromSection(providerConfigRoot, "chat", "textPrompt", AppKeys.TEXT_PROMPT.defaultValue);
imagePrompt = getFromSection(providerConfigRoot, "image", "imagePrompt", AppKeys.IMAGE_PROMPT.defaultValue);
imageSize = getFromSection(providerConfigRoot, "image", "size", AppKeys.IMAGE_SIZE.defaultValue);
listenerIndexer = getFromSection(providerConfigRoot, "embeddings", "listenerIndexer", AppKeys.LISTENER_INDEXER.defaultValue);

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

Expand Down Expand Up @@ -327,7 +329,7 @@ public String getProviderConfig() {
}

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

private static String getFromSection(final JsonNode root, final String section,
final String field, final String defaultValue) {
try {
final JsonNode sectionNode = root.get(section);
if (sectionNode == null || sectionNode.isNull()) {
return defaultValue;
}
final JsonNode fieldNode = sectionNode.get(field);
if (fieldNode == null || fieldNode.isNull()) {
return defaultValue;
}
// Container nodes (object/array) are serialized back to a JSON string (e.g. listenerIndexer)
final String value = fieldNode.isContainerNode() ? fieldNode.toString() : fieldNode.asText();
return StringUtils.isNotBlank(value) ? value : defaultValue;
} catch (final Exception e) {
return defaultValue;
}
}

@com.google.common.annotations.VisibleForTesting
static JsonNode parseProviderConfig(final String json) {
try {
Expand Down
Loading
Loading