@hahnpro/ai-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/hahnpro-ai-sdk.mjs +21 -31
- package/fesm2022/hahnpro-ai-sdk.mjs.map +1 -1
- package/lib/ai/chat-dialog/chat-dialog.component.d.ts +12 -31
- package/lib/ai/context.service.d.ts +1 -1
- package/lib/ai/transloco.module.d.ts +2 -0
- package/lib/core/api.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -46,9 +46,9 @@ import { pdfDefaultOptions, NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-
|
|
|
46
46
|
import { HttpClient as HttpClient$1, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
47
47
|
|
|
48
48
|
class ApiService {
|
|
49
|
-
_baseUrl = 'https://
|
|
49
|
+
_baseUrl = 'https://adam.hahnpro.com';
|
|
50
50
|
apiPath = '/api';
|
|
51
|
-
realm = '
|
|
51
|
+
realm = 'adam';
|
|
52
52
|
httpClient = new HttpClient();
|
|
53
53
|
get baseUrl() {
|
|
54
54
|
return this._baseUrl;
|
|
@@ -59,7 +59,9 @@ class ApiService {
|
|
|
59
59
|
get user() {
|
|
60
60
|
return this.httpClient.user;
|
|
61
61
|
}
|
|
62
|
-
init(clientId, clientSecret) {
|
|
62
|
+
init(clientId, clientSecret, baseUrl, realm) {
|
|
63
|
+
this._baseUrl = baseUrl || 'https://adam.hahnpro.com';
|
|
64
|
+
this.realm = realm || 'adam';
|
|
63
65
|
return this.httpClient.init(`${this.baseUrl}/auth/realms/${this.realm}`, clientId, clientSecret);
|
|
64
66
|
}
|
|
65
67
|
getAccessToken() {
|
|
@@ -573,6 +575,7 @@ const translations = {
|
|
|
573
575
|
},
|
|
574
576
|
prompts: {
|
|
575
577
|
asset: "I have a question related to the Asset '{{assetName}}' with ID {{assetId}}",
|
|
578
|
+
'ext-asset': "I have a question related to the Asset '{{assetName}}' with external Key {{assetKey}}",
|
|
576
579
|
help: "Please help me solve this task for the asset '{{assetName}}' (ID: {{assetId}}): {{task}}",
|
|
577
580
|
incident: "Please create a new incident for the asset '{{assetName}}' (ID: {{assetId}}) of type '{{assetTypeName}}' (ID: {{assetTypeId}}')",
|
|
578
581
|
report: "I have completed the following task for asset '{{assetName}}' (ID: {{assetId}}). Please create a report about it: {{task}}",
|
|
@@ -1179,6 +1182,7 @@ const translations = {
|
|
|
1179
1182
|
},
|
|
1180
1183
|
prompts: {
|
|
1181
1184
|
asset: "Ich habe eine Frage zu dem Asset '{{assetName}}' mit der ID {{assetId}}",
|
|
1185
|
+
'ext-asset': "Ich habe eine Frage zu dem Asset '{{assetName}}' mit der externen ID {{assetKey}}",
|
|
1182
1186
|
help: "Bitte hilf mir bei der Lösung dieser Aufgabe für das Asset '{{assetName}}' (ID: {{assetId}}): {{task}}",
|
|
1183
1187
|
incident: "Bitte erstelle eine neue Meldung für das Asset '{{assetName}}' (ID: {{assetId}}) vom Typ '{{assetTypeName}}' (ID: {{assetTypeId}}')",
|
|
1184
1188
|
report: "Ich habe folgende Aufgabe für das Asset '{{assetName}}' (ID: {{assetId}}) abgeschlossen. Bitte erstelle einen Bericht dazu: {{task}}",
|
|
@@ -2127,13 +2131,15 @@ class ChatService {
|
|
|
2127
2131
|
if (!this._activeAssistant) {
|
|
2128
2132
|
throw new Error(`Assistant ${assistantId} not found`);
|
|
2129
2133
|
}
|
|
2130
|
-
|
|
2131
|
-
this._activeThread = await this.apiService.getThread(
|
|
2134
|
+
this._activeThread = await this.apiService.createThread(assistantId);
|
|
2135
|
+
// this._activeThread = await this.apiService.getThread(
|
|
2136
|
+
// '67ed93d38361957d6811b944',
|
|
2137
|
+
// );
|
|
2132
2138
|
await this.getMessages();
|
|
2133
2139
|
this.setupWebsockets();
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2140
|
+
if (initialMessage) {
|
|
2141
|
+
await this.sendMessage(initialMessage, hidden);
|
|
2142
|
+
}
|
|
2137
2143
|
}
|
|
2138
2144
|
catch (err) {
|
|
2139
2145
|
console.error(err);
|
|
@@ -3328,47 +3334,31 @@ class AiChatDialogComponent {
|
|
|
3328
3334
|
data;
|
|
3329
3335
|
matDialogRef;
|
|
3330
3336
|
chatService = inject(ChatService);
|
|
3331
|
-
confirm;
|
|
3332
3337
|
type = 'asset';
|
|
3333
3338
|
asset;
|
|
3334
|
-
event;
|
|
3335
|
-
task;
|
|
3336
3339
|
logger = inject(NGXLogger);
|
|
3337
3340
|
translocoService = inject(TranslocoService);
|
|
3338
3341
|
constructor(data, matDialogRef, matIconRegistry, domSanitizer) {
|
|
3339
3342
|
this.data = data;
|
|
3340
3343
|
this.matDialogRef = matDialogRef;
|
|
3341
3344
|
this.asset = data.asset;
|
|
3342
|
-
this.
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
this.type = data.type || 'asset';
|
|
3345
|
+
if (this.asset.externalKey && !this.asset.id) {
|
|
3346
|
+
this.type = 'ext-asset';
|
|
3347
|
+
}
|
|
3346
3348
|
const blob = new Blob([svgString], { type: 'image/svg+xml' });
|
|
3347
3349
|
const url = URL.createObjectURL(blob);
|
|
3348
3350
|
matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl(url));
|
|
3349
3351
|
}
|
|
3350
3352
|
ngOnInit() {
|
|
3351
|
-
let task = {};
|
|
3352
|
-
if (this.task) {
|
|
3353
|
-
task = {
|
|
3354
|
-
name: this.task.name,
|
|
3355
|
-
reason: this.task.reason,
|
|
3356
|
-
description: this.task.description,
|
|
3357
|
-
priority: this.task.priority,
|
|
3358
|
-
};
|
|
3359
|
-
}
|
|
3360
3353
|
this.chatService
|
|
3361
3354
|
.init()
|
|
3362
3355
|
.then(async () => {
|
|
3363
3356
|
const initialMessage = this.translocoService.translate('ai.prompts.' + this.type, {
|
|
3364
3357
|
assetId: this.asset?.id,
|
|
3365
3358
|
assetName: this.asset?.name,
|
|
3366
|
-
|
|
3367
|
-
assetTypeName: this.asset?.type?.name,
|
|
3368
|
-
task: JSON.stringify(task),
|
|
3359
|
+
assetKey: this.asset?.externalKey,
|
|
3369
3360
|
});
|
|
3370
|
-
const
|
|
3371
|
-
const assistantId = type + '-assistant';
|
|
3361
|
+
const assistantId = 'asset-assistant';
|
|
3372
3362
|
await this.chatService.createThreadForModal(assistantId, initialMessage);
|
|
3373
3363
|
})
|
|
3374
3364
|
.catch((err) => {
|
|
@@ -3380,7 +3370,7 @@ class AiChatDialogComponent {
|
|
|
3380
3370
|
this.matDialogRef.close(message);
|
|
3381
3371
|
}
|
|
3382
3372
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: AiChatDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i3$1.MatDialogRef }, { token: i2$2.MatIconRegistry }, { token: i3$3.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
|
|
3383
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
3373
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.4", type: AiChatDialogComponent, isStandalone: true, selector: "ng-component", providers: [ChatService, ContextService, WebsocketService], ngImport: i0, template: "<div class=\"flex h-full w-full flex-col\" *transloco=\"let t\">\n <div class=\"flex justify-end pb-2\">\n <button\n mat-icon-button\n (click)=\"close()\"\n class=\"small bg-zinc-50 text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:bg-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-50\"\n >\n <mat-icon svgIcon=\"dismiss\"></mat-icon>\n </button>\n </div>\n <div\n class=\"flex h-full w-full flex-col items-center overflow-y-auto\"\n aiChatScroll\n >\n <ai-thread class=\"flex h-full w-full\"></ai-thread>\n </div>\n <ai-message-input class=\"w-full\"></ai-message-input>\n</div>\n", dependencies: [{ kind: "ngmodule", type: AiTranslocoModule }, { kind: "directive", type: i4.TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "directive", type: ChatScrollDirective, selector: "[aiChatScroll]" }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: LoggerModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2$1.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: MessageInputComponent, selector: "ai-message-input", inputs: ["startConversation"] }, { kind: "component", type: ThreadComponent, selector: "ai-thread" }] });
|
|
3384
3374
|
}
|
|
3385
3375
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: AiChatDialogComponent, decorators: [{
|
|
3386
3376
|
type: Component,
|
|
@@ -3399,7 +3389,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
|
|
|
3399
3389
|
MatProgressSpinnerModule,
|
|
3400
3390
|
MessageInputComponent,
|
|
3401
3391
|
ThreadComponent,
|
|
3402
|
-
], providers: [ChatService, ContextService, WebsocketService], template: "<div class=\"flex h-full w-full flex-col\" *transloco=\"let t\">\n <div class=\"flex justify-end pb-2\">\n <button\n mat-icon-button\n (click)=\"close()\"\n class=\"small bg-zinc-50 text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:bg-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-50\"\n >\n <mat-icon svgIcon=\"dismiss\"></mat-icon>\n </button>\n </div>\n <div\n class=\"flex h-full w-full flex-col items-center overflow-y-auto\"\n aiChatScroll\n >\n <ai-thread class=\"flex h-full w-full\"></ai-thread>\n </div>\n <ai-message-input class=\"w-full\"></ai-message-input>\n
|
|
3392
|
+
], providers: [ChatService, ContextService, WebsocketService], template: "<div class=\"flex h-full w-full flex-col\" *transloco=\"let t\">\n <div class=\"flex justify-end pb-2\">\n <button\n mat-icon-button\n (click)=\"close()\"\n class=\"small bg-zinc-50 text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:bg-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-50\"\n >\n <mat-icon svgIcon=\"dismiss\"></mat-icon>\n </button>\n </div>\n <div\n class=\"flex h-full w-full flex-col items-center overflow-y-auto\"\n aiChatScroll\n >\n <ai-thread class=\"flex h-full w-full\"></ai-thread>\n </div>\n <ai-message-input class=\"w-full\"></ai-message-input>\n</div>\n" }]
|
|
3403
3393
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3404
3394
|
type: Inject,
|
|
3405
3395
|
args: [MAT_DIALOG_DATA]
|