-
Notifications
You must be signed in to change notification settings - Fork 480
feat(dotAI): Dot AI LangChain4J - Custom UI for provider config #35445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 99944b6
fix(dotAI): restore original YAML description, remove redundant field…
ihoffmann-dot 12dbb1f
fix(dotAI): set providerConfig as visible field (hidden: false)
ihoffmann-dot 1302acd
fix(dotAI): disable allowExtraParameters to remove Custom Properties …
ihoffmann-dot 5805599
temp: revert allowExtraParameters to true for cleanup
ihoffmann-dot 1f1f494
feat(ai): multi-model fallback via comma-separated model field
ihoffmann-dot 5cb58a2
refactor(ai): remove PUT config endpoint and ProviderConfigMerger
ihoffmann-dot d010f7f
refactor(ai): extract executeWithFallback helper in LangChain4jAIClient
ihoffmann-dot 5c73e87
fix(postman): update AI collection for providerConfig consolidation
ihoffmann-dot b6321ca
fix(ai): move listenerIndexer into providerConfig in AiTest setup
ihoffmann-dot 9985b5b
Merge branch 'main' into dot-ai-langchain-fixes
ihoffmann-dot 74bea41
feat(ai): custom UI and PUT endpoint for dotAI provider config
ihoffmann-dot f7d63b9
refactor(ai): address PR review comments on LangChain4jAIClient and P…
ihoffmann-dot 4bfd48a
feat(ai): auto-route maxTokens to max_completion_tokens for OpenAI re…
ihoffmann-dot b7451fa
revert(ai): keep model() as @Nullable String in ProviderConfig
ihoffmann-dot 3711fd1
fix(ai): flush SSE chunks, cancelled flag on IOException, maxRetries …
ihoffmann-dot a6dae0d
fix(ai): null check in parseSection, deepCopy in injectApiKeyIntoSect…
ihoffmann-dot fc368f1
feat(ai): two-column UI, fix resolver, rendering bug, dotAI.yml descr…
ihoffmann-dot 7eb1996
Merge branch 'main' into dot-ai-langchain-custom-ui
ihoffmann-dot 43d1a65
fix(ai): immutable allModels(), fallback tests, self-import, javadoc,…
ihoffmann-dot cbcd812
test(ai): ProviderConfigMerger unit tests + Postman PUT config tests
ihoffmann-dot 0ae65cd
fix(postman): use invalid credentials in Config-Unauthorized test
ihoffmann-dot 8fb6fd3
fix(ai): address PR review issues #1-#6 #8
ihoffmann-dot e8ec864
fix(postman): clear JSESSIONID before unauthorized test to force 401
ihoffmann-dot 871913e
test(postman): remove Config-Unauthorized test (Newman cookie jar lim…
ihoffmann-dot 2169709
fix(ai): address PR review issues #1 #2 #4 #6
ihoffmann-dot cc99a42
refactor(ai): signals, takeUntilDestroyed, Tailwind, p-button
ihoffmann-dot c3cc0cf
fix(ai): sentinel guard, move DotAiProviderConfig to models, fix goTo…
ihoffmann-dot c6f82c1
fix(ai): replace containsMasked with containsMaskedCredential in post…
ihoffmann-dot 1d90b9b
chore(ai): delete empty SCSS file
ihoffmann-dot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...ortlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail-resolver.service.ts
This file contains hidden or 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 @@ | ||
| 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)); | ||
| }; |
38 changes: 38 additions & 0 deletions
38
...app/portlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail.component.html
This file contains hidden or 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,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> | ||
| } |
157 changes: 157 additions & 0 deletions
157
...c/app/portlets/dot-apps/components/dot-ai-config-detail/dot-ai-config-detail.component.ts
This file contains hidden or 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,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 | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| 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 | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
zJaaal marked this conversation as resolved.
|
||
|
|
||
| goToApps(): void { | ||
| const key = this.app()?.key ?? 'dotAI'; | ||
| this.dotRouterService.goToAppsConfiguration(key); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.