@liip/liipgpt 0.0.24 → 1.0.0-rc.1

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/lib/markdown.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ChatMessageBot } from './chat-message-types';
2
- export declare const toHTML: (markdown: string, lastMessage: ChatMessageBot) => string | Promise<string>;
1
+ import { References } from '../../../../../src/lib/chat-message-types';
2
+ export declare const toHTML: (markdown: string, references: References) => string;
@@ -0,0 +1,15 @@
1
+ import { ChatErrors, ChatMessageBot, ChatMessageBotStreaming, OnError } from '../../../../../src/lib/chat-message-types';
2
+ import { SseReference } from '../../../../../src/lib/sse-v2-types';
3
+ import { Readable } from 'svelte/store';
4
+ export declare const hasId: (message: ChatMessageBot) => message is ChatMessageBotStreaming;
5
+ export declare class MessageStore {
6
+ private onError?;
7
+ private store;
8
+ constructor(onError?: OnError | undefined);
9
+ pushError(error: ChatErrors): void;
10
+ updateRequestId(id: string): void;
11
+ updateText(text: string): void;
12
+ finishMessage(): void;
13
+ addReference(reference: SseReference): void;
14
+ getReadable(): Readable<ChatMessageBot>;
15
+ }
@@ -0,0 +1,57 @@
1
+ interface UsedLinks {
2
+ url: string;
3
+ title: string;
4
+ type?: string;
5
+ image?: string;
6
+ smallImage?: string;
7
+ date?: Date;
8
+ description?: string;
9
+ considered: boolean;
10
+ similarity?: number;
11
+ content?: string;
12
+ contentDescription?: boolean;
13
+ fromFullTextSearch?: boolean;
14
+ summary?: string;
15
+ doNotSendLink?: boolean;
16
+ }
17
+ export type SseReference = Omit<UsedLinks, 'content'>;
18
+ export type ServerError = 'blocked' | 'maintenance' | 'rate-limit' | 'server-error' | 'too-short' | 'too-long' | 'quota-reached' | 'aborted';
19
+ export type SseMessageV2 = {
20
+ type: 'text';
21
+ text: string;
22
+ } | {
23
+ type: 'state';
24
+ state: 'retrieve' | 'interpret' | 'generate-prompt' | 'generate-answer' | 'retry' | 'no-guarantee' | 'maybe-bad-rating' | 'no-question' | 'no-search' | 'analyze';
25
+ message?: string;
26
+ } | {
27
+ type: 'unexpected-call';
28
+ key?: string;
29
+ value: unknown;
30
+ } | {
31
+ type: 'error';
32
+ error: ServerError;
33
+ message?: string;
34
+ } | {
35
+ type: 'reference';
36
+ reference: SseReference;
37
+ } | {
38
+ type: 'tokens-per-second';
39
+ tps: number;
40
+ } | {
41
+ type: 'id';
42
+ for: 'request' | 'thread' | 'user';
43
+ id: string;
44
+ } | {
45
+ type: 'retrieval-question';
46
+ question: string;
47
+ } | {
48
+ type: 'language';
49
+ language: string;
50
+ } | {
51
+ type: 'answer-done';
52
+ } | {
53
+ type: 'done';
54
+ } | {
55
+ type: 'ignore';
56
+ };
57
+ export {};
package/lib/types.d.ts CHANGED
@@ -1,210 +1,202 @@
1
1
  import { z } from 'zod';
2
2
  export declare const classificationConfigSchema: z.ZodObject<{
3
- enabled: z.ZodBoolean;
4
- impact: z.ZodObject<{
3
+ impact: z.ZodOptional<z.ZodObject<{
5
4
  label: z.ZodString;
6
5
  options: z.ZodArray<z.ZodObject<{
7
6
  label: z.ZodString;
8
7
  value: z.ZodNumber;
9
8
  }, "strip", z.ZodTypeAny, {
10
- label: string;
11
9
  value: number;
12
- }, {
13
10
  label: string;
11
+ }, {
14
12
  value: number;
13
+ label: string;
15
14
  }>, "many">;
16
15
  }, "strip", z.ZodTypeAny, {
16
+ label: string;
17
17
  options: {
18
- label: string;
19
18
  value: number;
19
+ label: string;
20
20
  }[];
21
- label: string;
22
21
  }, {
22
+ label: string;
23
23
  options: {
24
- label: string;
25
24
  value: number;
25
+ label: string;
26
26
  }[];
27
- label: string;
28
- }>;
29
- quality: z.ZodObject<{
27
+ }>>;
28
+ quality: z.ZodOptional<z.ZodObject<{
30
29
  label: z.ZodString;
31
30
  options: z.ZodArray<z.ZodObject<{
32
31
  label: z.ZodString;
33
32
  value: z.ZodNumber;
34
33
  }, "strip", z.ZodTypeAny, {
35
- label: string;
36
34
  value: number;
37
- }, {
38
35
  label: string;
36
+ }, {
39
37
  value: number;
38
+ label: string;
40
39
  }>, "many">;
41
40
  }, "strip", z.ZodTypeAny, {
41
+ label: string;
42
42
  options: {
43
- label: string;
44
43
  value: number;
44
+ label: string;
45
45
  }[];
46
- label: string;
47
46
  }, {
47
+ label: string;
48
48
  options: {
49
- label: string;
50
49
  value: number;
50
+ label: string;
51
51
  }[];
52
- label: string;
53
- }>;
52
+ }>>;
54
53
  }, "strip", z.ZodTypeAny, {
55
- enabled: boolean;
56
- impact: {
54
+ impact?: {
55
+ label: string;
57
56
  options: {
58
- label: string;
59
57
  value: number;
58
+ label: string;
60
59
  }[];
60
+ } | undefined;
61
+ quality?: {
61
62
  label: string;
62
- };
63
- quality: {
64
63
  options: {
65
- label: string;
66
64
  value: number;
65
+ label: string;
67
66
  }[];
68
- label: string;
69
- };
67
+ } | undefined;
70
68
  }, {
71
- enabled: boolean;
72
- impact: {
69
+ impact?: {
70
+ label: string;
73
71
  options: {
74
- label: string;
75
72
  value: number;
73
+ label: string;
76
74
  }[];
75
+ } | undefined;
76
+ quality?: {
77
77
  label: string;
78
- };
79
- quality: {
80
78
  options: {
81
- label: string;
82
79
  value: number;
80
+ label: string;
83
81
  }[];
84
- label: string;
85
- };
82
+ } | undefined;
86
83
  }>;
87
84
  export declare const classificationResponseSchema: z.ZodObject<{
88
85
  classification: z.ZodOptional<z.ZodObject<{
89
- enabled: z.ZodBoolean;
90
- impact: z.ZodObject<{
86
+ impact: z.ZodOptional<z.ZodObject<{
91
87
  label: z.ZodString;
92
88
  options: z.ZodArray<z.ZodObject<{
93
89
  label: z.ZodString;
94
90
  value: z.ZodNumber;
95
91
  }, "strip", z.ZodTypeAny, {
96
- label: string;
97
92
  value: number;
98
- }, {
99
93
  label: string;
94
+ }, {
100
95
  value: number;
96
+ label: string;
101
97
  }>, "many">;
102
98
  }, "strip", z.ZodTypeAny, {
99
+ label: string;
103
100
  options: {
104
- label: string;
105
101
  value: number;
102
+ label: string;
106
103
  }[];
107
- label: string;
108
104
  }, {
105
+ label: string;
109
106
  options: {
110
- label: string;
111
107
  value: number;
108
+ label: string;
112
109
  }[];
113
- label: string;
114
- }>;
115
- quality: z.ZodObject<{
110
+ }>>;
111
+ quality: z.ZodOptional<z.ZodObject<{
116
112
  label: z.ZodString;
117
113
  options: z.ZodArray<z.ZodObject<{
118
114
  label: z.ZodString;
119
115
  value: z.ZodNumber;
120
116
  }, "strip", z.ZodTypeAny, {
121
- label: string;
122
117
  value: number;
123
- }, {
124
118
  label: string;
119
+ }, {
125
120
  value: number;
121
+ label: string;
126
122
  }>, "many">;
127
123
  }, "strip", z.ZodTypeAny, {
124
+ label: string;
128
125
  options: {
129
- label: string;
130
126
  value: number;
127
+ label: string;
131
128
  }[];
132
- label: string;
133
129
  }, {
130
+ label: string;
134
131
  options: {
135
- label: string;
136
132
  value: number;
133
+ label: string;
137
134
  }[];
138
- label: string;
139
- }>;
135
+ }>>;
140
136
  }, "strip", z.ZodTypeAny, {
141
- enabled: boolean;
142
- impact: {
137
+ impact?: {
138
+ label: string;
143
139
  options: {
144
- label: string;
145
140
  value: number;
141
+ label: string;
146
142
  }[];
143
+ } | undefined;
144
+ quality?: {
147
145
  label: string;
148
- };
149
- quality: {
150
146
  options: {
151
- label: string;
152
147
  value: number;
148
+ label: string;
153
149
  }[];
154
- label: string;
155
- };
150
+ } | undefined;
156
151
  }, {
157
- enabled: boolean;
158
- impact: {
152
+ impact?: {
153
+ label: string;
159
154
  options: {
160
- label: string;
161
155
  value: number;
156
+ label: string;
162
157
  }[];
158
+ } | undefined;
159
+ quality?: {
163
160
  label: string;
164
- };
165
- quality: {
166
161
  options: {
167
- label: string;
168
162
  value: number;
163
+ label: string;
169
164
  }[];
170
- label: string;
171
- };
165
+ } | undefined;
172
166
  }>>;
173
167
  }, "strip", z.ZodTypeAny, {
174
168
  classification?: {
175
- enabled: boolean;
176
- impact: {
169
+ impact?: {
170
+ label: string;
177
171
  options: {
178
- label: string;
179
172
  value: number;
173
+ label: string;
180
174
  }[];
175
+ } | undefined;
176
+ quality?: {
181
177
  label: string;
182
- };
183
- quality: {
184
178
  options: {
185
- label: string;
186
179
  value: number;
180
+ label: string;
187
181
  }[];
188
- label: string;
189
- };
182
+ } | undefined;
190
183
  } | undefined;
191
184
  }, {
192
185
  classification?: {
193
- enabled: boolean;
194
- impact: {
186
+ impact?: {
187
+ label: string;
195
188
  options: {
196
- label: string;
197
189
  value: number;
190
+ label: string;
198
191
  }[];
192
+ } | undefined;
193
+ quality?: {
199
194
  label: string;
200
- };
201
- quality: {
202
195
  options: {
203
- label: string;
204
196
  value: number;
197
+ label: string;
205
198
  }[];
206
- label: string;
207
- };
199
+ } | undefined;
208
200
  } | undefined;
209
201
  }>;
210
202
  export type ClassificationConfig = z.infer<typeof classificationConfigSchema>;
@@ -215,14 +207,14 @@ export declare const menuItemSchema: z.ZodObject<{
215
207
  url: z.ZodString;
216
208
  target: z.ZodString;
217
209
  }, "strip", z.ZodTypeAny, {
210
+ url: string;
218
211
  label: string;
219
212
  icon: string;
220
- url: string;
221
213
  target: string;
222
214
  }, {
215
+ url: string;
223
216
  label: string;
224
217
  icon: string;
225
- url: string;
226
218
  target: string;
227
219
  }>;
228
220
  export declare const chatConfigSchema: z.ZodObject<{
@@ -232,149 +224,144 @@ export declare const chatConfigSchema: z.ZodObject<{
232
224
  url: z.ZodString;
233
225
  target: z.ZodString;
234
226
  }, "strip", z.ZodTypeAny, {
227
+ url: string;
235
228
  label: string;
236
229
  icon: string;
237
- url: string;
238
230
  target: string;
239
231
  }, {
232
+ url: string;
240
233
  label: string;
241
234
  icon: string;
242
- url: string;
243
235
  target: string;
244
236
  }>, "many">>>;
245
237
  supportedLanguages: z.ZodOptional<z.ZodArray<z.ZodEnum<["en", "de", "fr", "it"]>, "many">>;
246
238
  classification: z.ZodOptional<z.ZodObject<{
247
- enabled: z.ZodBoolean;
248
- impact: z.ZodObject<{
239
+ impact: z.ZodOptional<z.ZodObject<{
249
240
  label: z.ZodString;
250
241
  options: z.ZodArray<z.ZodObject<{
251
242
  label: z.ZodString;
252
243
  value: z.ZodNumber;
253
244
  }, "strip", z.ZodTypeAny, {
254
- label: string;
255
245
  value: number;
256
- }, {
257
246
  label: string;
247
+ }, {
258
248
  value: number;
249
+ label: string;
259
250
  }>, "many">;
260
251
  }, "strip", z.ZodTypeAny, {
252
+ label: string;
261
253
  options: {
262
- label: string;
263
254
  value: number;
255
+ label: string;
264
256
  }[];
265
- label: string;
266
257
  }, {
258
+ label: string;
267
259
  options: {
268
- label: string;
269
260
  value: number;
261
+ label: string;
270
262
  }[];
271
- label: string;
272
- }>;
273
- quality: z.ZodObject<{
263
+ }>>;
264
+ quality: z.ZodOptional<z.ZodObject<{
274
265
  label: z.ZodString;
275
266
  options: z.ZodArray<z.ZodObject<{
276
267
  label: z.ZodString;
277
268
  value: z.ZodNumber;
278
269
  }, "strip", z.ZodTypeAny, {
279
- label: string;
280
270
  value: number;
281
- }, {
282
271
  label: string;
272
+ }, {
283
273
  value: number;
274
+ label: string;
284
275
  }>, "many">;
285
276
  }, "strip", z.ZodTypeAny, {
277
+ label: string;
286
278
  options: {
287
- label: string;
288
279
  value: number;
280
+ label: string;
289
281
  }[];
290
- label: string;
291
282
  }, {
283
+ label: string;
292
284
  options: {
293
- label: string;
294
285
  value: number;
286
+ label: string;
295
287
  }[];
296
- label: string;
297
- }>;
288
+ }>>;
298
289
  }, "strip", z.ZodTypeAny, {
299
- enabled: boolean;
300
- impact: {
290
+ impact?: {
291
+ label: string;
301
292
  options: {
302
- label: string;
303
293
  value: number;
294
+ label: string;
304
295
  }[];
296
+ } | undefined;
297
+ quality?: {
305
298
  label: string;
306
- };
307
- quality: {
308
299
  options: {
309
- label: string;
310
300
  value: number;
301
+ label: string;
311
302
  }[];
312
- label: string;
313
- };
303
+ } | undefined;
314
304
  }, {
315
- enabled: boolean;
316
- impact: {
305
+ impact?: {
306
+ label: string;
317
307
  options: {
318
- label: string;
319
308
  value: number;
309
+ label: string;
320
310
  }[];
311
+ } | undefined;
312
+ quality?: {
321
313
  label: string;
322
- };
323
- quality: {
324
314
  options: {
325
- label: string;
326
315
  value: number;
316
+ label: string;
327
317
  }[];
328
- label: string;
329
- };
318
+ } | undefined;
330
319
  }>>;
331
320
  }, "strip", z.ZodTypeAny, {
332
321
  classification?: {
333
- enabled: boolean;
334
- impact: {
322
+ impact?: {
323
+ label: string;
335
324
  options: {
336
- label: string;
337
325
  value: number;
326
+ label: string;
338
327
  }[];
328
+ } | undefined;
329
+ quality?: {
339
330
  label: string;
340
- };
341
- quality: {
342
331
  options: {
343
- label: string;
344
332
  value: number;
333
+ label: string;
345
334
  }[];
346
- label: string;
347
- };
335
+ } | undefined;
348
336
  } | undefined;
349
337
  menu?: Record<string, {
338
+ url: string;
350
339
  label: string;
351
340
  icon: string;
352
- url: string;
353
341
  target: string;
354
342
  }[]> | undefined;
355
343
  supportedLanguages?: ("en" | "de" | "fr" | "it")[] | undefined;
356
344
  }, {
357
345
  classification?: {
358
- enabled: boolean;
359
- impact: {
346
+ impact?: {
347
+ label: string;
360
348
  options: {
361
- label: string;
362
349
  value: number;
350
+ label: string;
363
351
  }[];
352
+ } | undefined;
353
+ quality?: {
364
354
  label: string;
365
- };
366
- quality: {
367
355
  options: {
368
- label: string;
369
356
  value: number;
357
+ label: string;
370
358
  }[];
371
- label: string;
372
- };
359
+ } | undefined;
373
360
  } | undefined;
374
361
  menu?: Record<string, {
362
+ url: string;
375
363
  label: string;
376
364
  icon: string;
377
- url: string;
378
365
  target: string;
379
366
  }[]> | undefined;
380
367
  supportedLanguages?: ("en" | "de" | "fr" | "it")[] | undefined;
package/lib/utils.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import { ReferenceData, Sources } from '../../../../../src/lib/liipgpt-client';
2
- import { SSESource } from './sse-types';
3
1
  export declare const removeUndefinedValues: (obj: Record<string, unknown>) => Record<string, string>;
4
2
  export declare const getDomainName: (url: string) => string;
5
- export declare const mapSSESource: (sseSource: SSESource) => ReferenceData;
6
- export declare const addSourceToSources: (sources: Sources, newSource: SSESource) => Sources;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liip/liipgpt",
3
- "version": "0.0.24",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "LiipGPT Chat and Library",
5
5
  "types": "./lib/liipgpt-client.d.ts",
6
6
  "module": "./lib/liipgpt-client.js",
@@ -1,17 +0,0 @@
1
- /**
2
- * The built-in node.scrollIntoView() and window.scrollTo() don't
3
- * work well while updating the content (and height/width) of the
4
- * page/container, as the duration of the scroll is defined by the
5
- * browser and the animated scroll bugs if there is a DOM change
6
- * during the animation.
7
- *
8
- * For such cases, a custom scroll animation with RFA and absolute
9
- * value works better, as it isn't impacted from DOM change.
10
- */
11
- export type ScrollDirection = 'scrollLeft' | 'scrollTop';
12
- declare global {
13
- interface HTMLElementEventMap {
14
- scrollcomplete: CustomEvent;
15
- }
16
- }
17
- export default function smoothScrollTo(node: HTMLElement | Window, scrollValue: number, duration: number, direction: ScrollDirection, easeFunction: (t: number) => number): void;
@@ -1,21 +0,0 @@
1
- export type SSESource = {
2
- usedLinks: {
3
- url: string;
4
- title?: string;
5
- image?: string;
6
- description?: string;
7
- domainName: string;
8
- date: string;
9
- number: number;
10
- content: string;
11
- contentDescription: false;
12
- similarity: number;
13
- considered: boolean;
14
- summary?: string;
15
- smallImage?: string;
16
- };
17
- };
18
- export type SSEResponse = SSESource | {
19
- response: string;
20
- id: string;
21
- };
package/lib/tooltip.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare function tooltip(node: HTMLElement, params: {
2
- text: string;
3
- position?: 'top' | 'bottom' | 'left' | 'right';
4
- delay?: number;
5
- }): {
6
- update(newParams: {
7
- text: string;
8
- position?: "top" | "bottom" | "left" | "right";
9
- delay?: number;
10
- }): void;
11
- destroy(): void;
12
- };