@hahnpro/ai-sdk 0.8.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/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, Message, Paginated, Thread, SpeechToken, RequestParameter, Asset, AssetType, Content, Event } from '@hahnpro/hpc-api';
5
- import * as i1$1 from '@angular/common';
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 { Observable } from 'rxjs';
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,10 +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;
141
+ context?: Record<string, unknown>;
142
+ messageHandler?: (message: {
143
+ type: WebSocketMessageType;
144
+ data: Message;
145
+ }) => void;
146
+ messageFilter?: WebSocketMessageType[];
126
147
  }
127
148
  declare class AiChatDialogComponent implements OnInit {
128
149
  data: ChatDialogData;
@@ -141,6 +162,96 @@ declare class AiChatDialogComponent implements OnInit {
141
162
  static ɵcmp: i0.ɵɵComponentDeclaration<AiChatDialogComponent, "ng-component", never, {}, {}, never, never, true, never>;
142
163
  }
143
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
+
144
255
  declare const translations: {
145
256
  en: {
146
257
  accepted: string;
@@ -1416,70 +1527,6 @@ declare class AiModule {
1416
1527
  static ɵinj: i0.ɵɵInjectorDeclaration<AiModule>;
1417
1528
  }
1418
1529
 
1419
- declare class ApiService {
1420
- private _baseUrl;
1421
- private apiPath;
1422
- private realm;
1423
- private httpClient;
1424
- get baseUrl(): string;
1425
- get apiUrl(): string;
1426
- get user(): User | null;
1427
- init(clientId: string, clientSecret: string, baseUrl?: string, realm?: string): Promise<void>;
1428
- addMessage(message: string, threadId?: string, assistantId?: string, context?: Record<string, unknown>): Promise<Message>;
1429
- getAccessToken(): Promise<string>;
1430
- createThread(assistantId: string, isEphemeral?: boolean): Promise<ThreadPopulated>;
1431
- getThread(threadId: string): Promise<ThreadPopulated>;
1432
- getThreadMessages(threadId: string): Promise<Paginated<Message[]>>;
1433
- deleteThread(threadId: string): Promise<Thread>;
1434
- getAssistants(): Promise<AiAssistant[]>;
1435
- getSpeechToken(): Promise<SpeechToken>;
1436
- getAssets(params?: RequestParameter): Promise<Paginated<Asset[]>>;
1437
- getAssetTypes(params?: RequestParameter): Promise<Paginated<AssetType[]>>;
1438
- getContents(params?: RequestParameter): Promise<Paginated<Content[]>>;
1439
- getEvents(params?: RequestParameter): Promise<Paginated<Event[]>>;
1440
- downloadContent(id: string, type?: FileType): Promise<Blob>;
1441
- loadUsersAsPermissions(): Promise<Permission[]>;
1442
- static ɵfac: i0.ɵɵFactoryDeclaration<ApiService, never>;
1443
- static ɵprov: i0.ɵɵInjectableDeclaration<ApiService>;
1444
- }
1445
- type TokenOption = {
1446
- token?: string;
1447
- };
1448
- type Config = TokenOption & {
1449
- headers?: Record<string, string>;
1450
- params?: any;
1451
- };
1452
- declare class HttpClient {
1453
- private config;
1454
- private token;
1455
- private expiresAt;
1456
- private _user;
1457
- init(serverUrl: string, clientId: string, clientSecret: string): Promise<void>;
1458
- delete: <T>(url: string, config?: Config) => Promise<T>;
1459
- get: <T>(url: string, config?: Config) => Promise<T>;
1460
- post: <T>(url: string, data: any, config?: Config) => Promise<T>;
1461
- put: <T>(url: string, data: any, config?: Config) => Promise<T>;
1462
- get user(): User | null;
1463
- protected request: <T>(method: Method, url: string, config?: Config, data?: BodyInit | null | undefined) => Promise<T>;
1464
- getAccessToken(): Promise<string>;
1465
- private resolveUser;
1466
- }
1467
- type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
1468
- type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
1469
- interface Permission {
1470
- label: string;
1471
- value: string;
1472
- }
1473
- interface User {
1474
- id: string;
1475
- username: string;
1476
- activeOrg?: {
1477
- id: string;
1478
- name: string;
1479
- };
1480
- roles: string[];
1481
- }
1482
-
1483
1530
  /**
1484
1531
  * Provides Markdown configuration for AI SDK
1485
1532
  * This allows consuming applications to not have to set up Markdown themselves
@@ -1492,5 +1539,5 @@ declare function provideAiMarkdown(): Provider;
1492
1539
  */
1493
1540
  declare function provideAiSdk(): (Provider | EnvironmentProviders)[];
1494
1541
 
1495
- export { AiChatDialogComponent, AiModule, AiTranslocoLoader, AiTranslocoModule, ApiService, HttpClient, provideAiMarkdown, provideAiSdk, translations };
1496
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/ai-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },