@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/README.md +40 -19
- package/chat/index.html +1 -1
- package/chat/liipgpt-chat.iife.js +278 -584
- package/lib/chat-message-types.d.ts +41 -30
- package/lib/liipgpt-client.d.ts +9 -14
- package/lib/liipgpt-client.js +2213 -2139
- package/lib/liipgpt-client.umd.cjs +38 -43
- package/lib/markdown.d.ts +2 -2
- package/lib/message-store.d.ts +15 -0
- package/lib/sse-v2-types.d.ts +57 -0
- package/lib/types.d.ts +124 -137
- package/lib/utils.d.ts +0 -4
- package/package.json +1 -1
- package/lib/smooth-scroll.d.ts +0 -17
- package/lib/sse-types.d.ts +0 -21
- package/lib/tooltip.d.ts +0 -12
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type
|
|
1
|
+
import { ServerError } from '../../../../../src/lib/sse-v2-types';
|
|
2
|
+
export type Reference = {
|
|
3
|
+
url: string;
|
|
4
|
+
referencesIndex: {
|
|
5
|
+
all: number;
|
|
6
|
+
used?: number;
|
|
7
|
+
};
|
|
8
|
+
considered: boolean;
|
|
9
|
+
display: {
|
|
10
|
+
card: {
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
badge?: string;
|
|
14
|
+
breadcrumb?: string[];
|
|
15
|
+
};
|
|
16
|
+
listItem: {
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
badge?: string;
|
|
20
|
+
breadcrumb?: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type References = {
|
|
25
|
+
all: Reference[];
|
|
26
|
+
used: Reference[];
|
|
27
|
+
};
|
|
28
|
+
export type ChatMessageBotStreaming = {
|
|
3
29
|
type: 'bot';
|
|
4
30
|
/**
|
|
5
31
|
* ISO Timestamp
|
|
6
32
|
*/
|
|
7
33
|
time: string;
|
|
8
34
|
id: string;
|
|
35
|
+
state: 'streaming' | 'done';
|
|
9
36
|
message: {
|
|
10
37
|
markdown: string;
|
|
11
38
|
html: string;
|
|
12
39
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
type ChatMessageLoading = {
|
|
17
|
-
type: 'bot-loading';
|
|
18
|
-
/**
|
|
19
|
-
* ISO Timestamp
|
|
20
|
-
*/
|
|
21
|
-
time: string;
|
|
40
|
+
references: References;
|
|
41
|
+
errors: ChatErrors[];
|
|
22
42
|
};
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* ISO Timestamp
|
|
27
|
-
*/
|
|
28
|
-
time: string;
|
|
29
|
-
id: string;
|
|
30
|
-
message: string;
|
|
31
|
-
};
|
|
32
|
-
type ChatMessageUser = {
|
|
33
|
-
type: 'user';
|
|
34
|
-
/**
|
|
35
|
-
* ISO Timestamp
|
|
36
|
-
*/
|
|
37
|
-
time: string;
|
|
38
|
-
message: string;
|
|
39
|
-
betterQuestion?: string;
|
|
43
|
+
export type ChatMessageBotLoading = Omit<ChatMessageBotStreaming, 'id' | 'state'> & {
|
|
44
|
+
id?: string;
|
|
45
|
+
state: 'loading';
|
|
40
46
|
};
|
|
41
|
-
export type
|
|
42
|
-
export {
|
|
47
|
+
export type ChatMessageBotRaw = ChatMessageBotLoading | ChatMessageBotStreaming;
|
|
48
|
+
export type ChatMessageBot = ChatMessageBotRaw | (Omit<ChatMessageBotRaw, 'id'> & {
|
|
49
|
+
id: undefined;
|
|
50
|
+
incomplete: true;
|
|
51
|
+
});
|
|
52
|
+
export type ChatErrors = ServerError | 'sse-error' | 'client-error' | 'unexpected-call' | 'incomplete-error';
|
|
53
|
+
export type OnError = (error: ChatErrors) => void;
|
package/lib/liipgpt-client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ClassificationConfig, MenuItem, PredefinedQuestion } from '../../../../../src/lib/types';
|
|
2
2
|
import { Readable } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import { Constructor } from 'type-fest';
|
|
4
|
+
import { ChatMessageBot, OnError } from './chat-message-types';
|
|
4
5
|
type LiipGPTClientOptions = {
|
|
5
6
|
apiUrl: string;
|
|
6
7
|
apiKey?: string;
|
|
7
8
|
strict?: boolean;
|
|
9
|
+
EventSource?: Constructor<EventSource>;
|
|
8
10
|
};
|
|
9
11
|
export type Language = 'en' | 'de' | 'fr' | 'it';
|
|
10
12
|
export type ReferenceData = {
|
|
@@ -30,19 +32,12 @@ type MenuParams = {
|
|
|
30
32
|
url: string;
|
|
31
33
|
language: string;
|
|
32
34
|
};
|
|
33
|
-
type ChatResponse = {
|
|
34
|
-
state: 'loading';
|
|
35
|
-
} | {
|
|
36
|
-
state: 'error';
|
|
37
|
-
errorMessage?: string;
|
|
38
|
-
} | {
|
|
39
|
-
state: 'streaming' | 'done';
|
|
40
|
-
payload: ChatMessageBot;
|
|
41
|
-
};
|
|
42
35
|
export type ChatOptions = {
|
|
43
36
|
model?: string;
|
|
44
37
|
lang?: string;
|
|
45
38
|
modes?: string[];
|
|
39
|
+
version?: string;
|
|
40
|
+
onError?: OnError;
|
|
46
41
|
};
|
|
47
42
|
export type QuickFeedbackType = 'positive' | 'negative';
|
|
48
43
|
export type QuickFeedback = {
|
|
@@ -72,10 +67,11 @@ export declare class LiipGPTClient {
|
|
|
72
67
|
private readonly apiUrl;
|
|
73
68
|
private readonly apiKey;
|
|
74
69
|
private readonly strict;
|
|
70
|
+
private readonly EventSource;
|
|
75
71
|
lastRequestId: string | undefined;
|
|
76
72
|
private idToQuestionsMap;
|
|
77
73
|
metadata: Promise<ClientMetadata>;
|
|
78
|
-
constructor({ apiUrl, apiKey, strict }: LiipGPTClientOptions);
|
|
74
|
+
constructor({ apiUrl, apiKey, strict, EventSource: EventSourceOption }: LiipGPTClientOptions);
|
|
79
75
|
private getUserData;
|
|
80
76
|
static getInstance(): LiipGPTClient | undefined;
|
|
81
77
|
private postData;
|
|
@@ -90,8 +86,7 @@ export declare class LiipGPTClient {
|
|
|
90
86
|
getMenu(params: MenuParams): Promise<MenuItem[]>;
|
|
91
87
|
getUsedLanguages(): Promise<Language[]>;
|
|
92
88
|
private chatInternal;
|
|
93
|
-
chat(message: string, options?: ChatOptions): Readable<
|
|
94
|
-
search(query: string, options?: ChatOptions): Readable<
|
|
95
|
-
private transformURL;
|
|
89
|
+
chat(message: string, options?: ChatOptions): Readable<ChatMessageBot>;
|
|
90
|
+
search(query: string, options?: ChatOptions): Readable<ChatMessageBot>;
|
|
96
91
|
}
|
|
97
92
|
export {};
|