@hahnpro/ai-sdk 0.9.0 → 0.10.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 +93 -9
- package/fesm2022/hahnpro-ai-sdk.mjs.map +1 -1
- package/index.d.ts +120 -74
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { OnInit, Provider, EnvironmentProviders } from '@angular/core';
|
|
2
|
+
import { OnInit, ElementRef, Provider, EnvironmentProviders } from '@angular/core';
|
|
3
3
|
import * as _hahnpro_hpc_api from '@hahnpro/hpc-api';
|
|
4
|
-
import { AiAssistant, ThreadPopulated, AssistantMessage as AssistantMessage$1, SystemMessage, ToolMessage, UserMessage as UserMessage$1,
|
|
5
|
-
import
|
|
6
|
-
import * as i2 from 'ngx-logger';
|
|
4
|
+
import { Message, AiAssistant, ThreadPopulated, AssistantMessage as AssistantMessage$1, SystemMessage, ToolMessage, UserMessage as UserMessage$1, Paginated, Thread, SpeechToken, RequestParameter, Asset, AssetType, Content, Event } from '@hahnpro/hpc-api';
|
|
5
|
+
import { Subject, Observable } from 'rxjs';
|
|
7
6
|
import * as i1 from '@jsverse/transloco';
|
|
8
|
-
import { TranslocoLoader } from '@jsverse/transloco';
|
|
9
|
-
import
|
|
7
|
+
import { TranslocoService, TranslocoLoader } from '@jsverse/transloco';
|
|
8
|
+
import * as i2 from 'ngx-logger';
|
|
9
|
+
import { NGXLogger } from 'ngx-logger';
|
|
10
|
+
import * as i1$1 from '@angular/common';
|
|
10
11
|
|
|
11
12
|
interface ContextReference {
|
|
12
13
|
reference_id: number;
|
|
@@ -30,6 +31,10 @@ declare class ChatService {
|
|
|
30
31
|
model: string | null;
|
|
31
32
|
locale: string;
|
|
32
33
|
isProcessing: boolean;
|
|
34
|
+
threadEventSubject: Subject<{
|
|
35
|
+
type: WebSocketMessageType;
|
|
36
|
+
data: Message;
|
|
37
|
+
}>;
|
|
33
38
|
private readonly apiService;
|
|
34
39
|
private readonly contextService;
|
|
35
40
|
private readonly destroy$;
|
|
@@ -104,8 +109,18 @@ interface UserMessage extends UserMessage$1 {
|
|
|
104
109
|
parsedContent?: MessageContent;
|
|
105
110
|
}
|
|
106
111
|
type ChatMessage = AssistantMessage | SystemMessage | ToolMessage | UserMessage;
|
|
112
|
+
declare enum WebSocketMessageType {
|
|
113
|
+
AI_ABORTED = "ai_aborted",
|
|
114
|
+
AI_ABORT_FAILED = "ai_abort_failed",
|
|
115
|
+
AI_COMPLETE = "ai_complete",
|
|
116
|
+
AI_FAILED_TO_PROCESS = "ai_failed_to_process",
|
|
117
|
+
AI_INVALID_MESSAGE = "ai_invalid_message",
|
|
118
|
+
AI_MESSAGE = "ai_message",
|
|
119
|
+
AI_PARTIAL_MESSAGE = "ai_partial_message",
|
|
120
|
+
AI_PROCESSING = "ai_processing"
|
|
121
|
+
}
|
|
107
122
|
|
|
108
|
-
interface AssetData {
|
|
123
|
+
interface AssetData$1 {
|
|
109
124
|
id?: string;
|
|
110
125
|
name?: string;
|
|
111
126
|
externalKey?: string;
|
|
@@ -119,11 +134,16 @@ interface EventData {
|
|
|
119
134
|
}
|
|
120
135
|
type ChatAssistantType = 'asset' | 'help' | 'report' | 'incident';
|
|
121
136
|
interface ChatDialogData {
|
|
122
|
-
asset?: AssetData;
|
|
137
|
+
asset?: AssetData$1;
|
|
123
138
|
event?: EventData;
|
|
124
139
|
assistant?: ChatAssistantType;
|
|
125
140
|
initialMessage?: string;
|
|
126
141
|
context?: Record<string, unknown>;
|
|
142
|
+
messageHandler?: (message: {
|
|
143
|
+
type: WebSocketMessageType;
|
|
144
|
+
data: Message;
|
|
145
|
+
}) => void;
|
|
146
|
+
messageFilter?: WebSocketMessageType[];
|
|
127
147
|
}
|
|
128
148
|
declare class AiChatDialogComponent implements OnInit {
|
|
129
149
|
data: ChatDialogData;
|
|
@@ -142,6 +162,96 @@ declare class AiChatDialogComponent implements OnInit {
|
|
|
142
162
|
static ɵcmp: i0.ɵɵComponentDeclaration<AiChatDialogComponent, "ng-component", never, {}, {}, never, never, true, never>;
|
|
143
163
|
}
|
|
144
164
|
|
|
165
|
+
declare class ApiService {
|
|
166
|
+
private _baseUrl;
|
|
167
|
+
private apiPath;
|
|
168
|
+
private realm;
|
|
169
|
+
private httpClient;
|
|
170
|
+
get baseUrl(): string;
|
|
171
|
+
get apiUrl(): string;
|
|
172
|
+
get user(): User | null;
|
|
173
|
+
init(clientId: string, clientSecret: string, baseUrl?: string, realm?: string): Promise<void>;
|
|
174
|
+
addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
|
|
175
|
+
getAccessToken(): Promise<string>;
|
|
176
|
+
createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
|
|
177
|
+
getThread(threadId: string): Promise<ThreadPopulated>;
|
|
178
|
+
getThreadMessages(threadId: string): Promise<Paginated<Message[]>>;
|
|
179
|
+
deleteThread(threadId: string): Promise<Thread>;
|
|
180
|
+
getAssistants(): Promise<AiAssistant[]>;
|
|
181
|
+
getSpeechToken(): Promise<SpeechToken>;
|
|
182
|
+
getAssets(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
183
|
+
getAssetTypes(params?: RequestParameter): Promise<Paginated<AssetType[]>>;
|
|
184
|
+
getContents(params?: RequestParameter): Promise<Paginated<Content[]>>;
|
|
185
|
+
getEvents(params?: RequestParameter): Promise<Paginated<Event[]>>;
|
|
186
|
+
downloadContent(id: string, type?: FileType): Promise<Blob>;
|
|
187
|
+
loadUsersAsPermissions(): Promise<Permission[]>;
|
|
188
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
|
|
189
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
|
|
190
|
+
}
|
|
191
|
+
type TokenOption = {
|
|
192
|
+
token?: string;
|
|
193
|
+
};
|
|
194
|
+
type Config = TokenOption & {
|
|
195
|
+
headers?: Record<string, string>;
|
|
196
|
+
params?: any;
|
|
197
|
+
};
|
|
198
|
+
declare class HttpClient {
|
|
199
|
+
private config;
|
|
200
|
+
private token;
|
|
201
|
+
private expiresAt;
|
|
202
|
+
private _user;
|
|
203
|
+
init(serverUrl: string, clientId: string, clientSecret: string): Promise<void>;
|
|
204
|
+
delete: <T>(url: string, config?: Config) => Promise<T>;
|
|
205
|
+
get: <T>(url: string, config?: Config) => Promise<T>;
|
|
206
|
+
post: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
207
|
+
put: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
208
|
+
get user(): User | null;
|
|
209
|
+
protected request: <T>(method: Method, url: string, config?: Config, data?: BodyInit | null | undefined) => Promise<T>;
|
|
210
|
+
getAccessToken(): Promise<string>;
|
|
211
|
+
private resolveUser;
|
|
212
|
+
}
|
|
213
|
+
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
214
|
+
type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
|
|
215
|
+
interface Permission {
|
|
216
|
+
label: string;
|
|
217
|
+
value: string;
|
|
218
|
+
}
|
|
219
|
+
interface User {
|
|
220
|
+
id: string;
|
|
221
|
+
username: string;
|
|
222
|
+
activeOrg?: {
|
|
223
|
+
id: string;
|
|
224
|
+
name: string;
|
|
225
|
+
};
|
|
226
|
+
roles: string[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface AssetData {
|
|
230
|
+
id?: string;
|
|
231
|
+
name?: string;
|
|
232
|
+
externalKey?: string;
|
|
233
|
+
}
|
|
234
|
+
interface AuthData {
|
|
235
|
+
clientId: string;
|
|
236
|
+
clientSecret: string;
|
|
237
|
+
baseUrl?: string;
|
|
238
|
+
realm?: string;
|
|
239
|
+
}
|
|
240
|
+
declare class AiChatComponent implements OnInit {
|
|
241
|
+
readonly apiService: ApiService;
|
|
242
|
+
readonly chatService: ChatService;
|
|
243
|
+
readonly translocoService: TranslocoService;
|
|
244
|
+
readonly logger: NGXLogger;
|
|
245
|
+
readonly elementRef: ElementRef<any>;
|
|
246
|
+
asset: AssetData;
|
|
247
|
+
authData: AuthData;
|
|
248
|
+
assistant: ChatAssistantType;
|
|
249
|
+
initialMessage?: string;
|
|
250
|
+
ngOnInit(): void;
|
|
251
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiChatComponent, never>;
|
|
252
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AiChatComponent, "ai-chat", never, { "asset": { "alias": "asset"; "required": false; }; "authData": { "alias": "authData"; "required": false; }; "assistant": { "alias": "assistant"; "required": false; }; "initialMessage": { "alias": "initialMessage"; "required": false; }; }, {}, never, never, true, never>;
|
|
253
|
+
}
|
|
254
|
+
|
|
145
255
|
declare const translations: {
|
|
146
256
|
en: {
|
|
147
257
|
accepted: string;
|
|
@@ -1417,70 +1527,6 @@ declare class AiModule {
|
|
|
1417
1527
|
static ɵinj: i0.ɵɵInjectorDeclaration<AiModule>;
|
|
1418
1528
|
}
|
|
1419
1529
|
|
|
1420
|
-
declare class ApiService {
|
|
1421
|
-
private _baseUrl;
|
|
1422
|
-
private apiPath;
|
|
1423
|
-
private realm;
|
|
1424
|
-
private httpClient;
|
|
1425
|
-
get baseUrl(): string;
|
|
1426
|
-
get apiUrl(): string;
|
|
1427
|
-
get user(): User | null;
|
|
1428
|
-
init(clientId: string, clientSecret: string, baseUrl?: string, realm?: string): Promise<void>;
|
|
1429
|
-
addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
|
|
1430
|
-
getAccessToken(): Promise<string>;
|
|
1431
|
-
createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
|
|
1432
|
-
getThread(threadId: string): Promise<ThreadPopulated>;
|
|
1433
|
-
getThreadMessages(threadId: string): Promise<Paginated<Message[]>>;
|
|
1434
|
-
deleteThread(threadId: string): Promise<Thread>;
|
|
1435
|
-
getAssistants(): Promise<AiAssistant[]>;
|
|
1436
|
-
getSpeechToken(): Promise<SpeechToken>;
|
|
1437
|
-
getAssets(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
1438
|
-
getAssetTypes(params?: RequestParameter): Promise<Paginated<AssetType[]>>;
|
|
1439
|
-
getContents(params?: RequestParameter): Promise<Paginated<Content[]>>;
|
|
1440
|
-
getEvents(params?: RequestParameter): Promise<Paginated<Event[]>>;
|
|
1441
|
-
downloadContent(id: string, type?: FileType): Promise<Blob>;
|
|
1442
|
-
loadUsersAsPermissions(): Promise<Permission[]>;
|
|
1443
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
|
|
1444
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
|
|
1445
|
-
}
|
|
1446
|
-
type TokenOption = {
|
|
1447
|
-
token?: string;
|
|
1448
|
-
};
|
|
1449
|
-
type Config = TokenOption & {
|
|
1450
|
-
headers?: Record<string, string>;
|
|
1451
|
-
params?: any;
|
|
1452
|
-
};
|
|
1453
|
-
declare class HttpClient {
|
|
1454
|
-
private config;
|
|
1455
|
-
private token;
|
|
1456
|
-
private expiresAt;
|
|
1457
|
-
private _user;
|
|
1458
|
-
init(serverUrl: string, clientId: string, clientSecret: string): Promise<void>;
|
|
1459
|
-
delete: <T>(url: string, config?: Config) => Promise<T>;
|
|
1460
|
-
get: <T>(url: string, config?: Config) => Promise<T>;
|
|
1461
|
-
post: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
1462
|
-
put: <T>(url: string, data: any, config?: Config) => Promise<T>;
|
|
1463
|
-
get user(): User | null;
|
|
1464
|
-
protected request: <T>(method: Method, url: string, config?: Config, data?: BodyInit | null | undefined) => Promise<T>;
|
|
1465
|
-
getAccessToken(): Promise<string>;
|
|
1466
|
-
private resolveUser;
|
|
1467
|
-
}
|
|
1468
|
-
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
1469
|
-
type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
|
|
1470
|
-
interface Permission {
|
|
1471
|
-
label: string;
|
|
1472
|
-
value: string;
|
|
1473
|
-
}
|
|
1474
|
-
interface User {
|
|
1475
|
-
id: string;
|
|
1476
|
-
username: string;
|
|
1477
|
-
activeOrg?: {
|
|
1478
|
-
id: string;
|
|
1479
|
-
name: string;
|
|
1480
|
-
};
|
|
1481
|
-
roles: string[];
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
1530
|
/**
|
|
1485
1531
|
* Provides Markdown configuration for AI SDK
|
|
1486
1532
|
* This allows consuming applications to not have to set up Markdown themselves
|
|
@@ -1493,5 +1539,5 @@ declare function provideAiMarkdown(): Provider;
|
|
|
1493
1539
|
*/
|
|
1494
1540
|
declare function provideAiSdk(): (Provider | EnvironmentProviders)[];
|
|
1495
1541
|
|
|
1496
|
-
export { AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, provideAiMarkdown, provideAiSdk, translations };
|
|
1497
|
-
export type { ChatAssistantType, ChatDialogData, Config, FileType, Method, Permission, TokenOption, User };
|
|
1542
|
+
export { AiChatComponent, AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, WebSocketMessageType, provideAiMarkdown, provideAiSdk, translations };
|
|
1543
|
+
export type { AssetData, AuthData, ChatAssistantType, ChatDialogData, Config, FileType, Method, Permission, TokenOption, User };
|