@liip/liipgpt 2.3.4 → 2.4.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/button/liipgpt-button.iife.js +5 -5
- package/chat/liipgpt-chat.iife.js +31 -29
- package/config/index.cjs +2 -1
- package/config/index.d.ts +7 -0
- package/config/index.js +2 -1
- package/configurator/_app/env.js +1 -1
- package/configurator/_app/immutable/chunks/{D9YRY7Z3.js → B1SAX13t.js} +1 -1
- package/configurator/_app/immutable/chunks/{DCUqa1sE.js → Bgk1m0O8.js} +1 -1
- package/configurator/_app/immutable/chunks/{BdfExRJ-.js → CMJv8DxQ.js} +1 -1
- package/configurator/_app/immutable/chunks/{DA1gqg6Q.js → COoGMG0q.js} +1 -1
- package/configurator/_app/immutable/chunks/{D3gC0ywi.js → CPije5QE.js} +1 -1
- package/configurator/_app/immutable/chunks/{DU5tWz-J.js → CSOT-TMw.js} +1 -1
- package/configurator/_app/immutable/chunks/{C4InYzKN.js → DIlqUbFX.js} +1 -1
- package/configurator/_app/immutable/chunks/SMXnfRO5.js +212 -0
- package/configurator/_app/immutable/chunks/{C1m9OPk7.js → ezaeL4Os.js} +1 -1
- package/configurator/_app/immutable/entry/{app.CmwL9eLu.js → app.Bnx0eV-L.js} +2 -2
- package/configurator/_app/immutable/entry/start.1zeU6pQ5.js +1 -0
- package/configurator/_app/immutable/nodes/{0.iAyovnQ-.js → 0.CvycOA52.js} +2 -1
- package/configurator/_app/immutable/nodes/{1.Cm2PHbvM.js → 1.C_OwhBk_.js} +1 -1
- package/configurator/_app/immutable/nodes/{2.D21_cUbr.js → 2.CJrAsi3s.js} +3 -3
- package/configurator/_app/immutable/nodes/{3.BQu0W3j9.js → 3.CYtkkAlU.js} +1 -1
- package/configurator/_app/version.json +1 -1
- package/configurator/index.html +6 -6
- package/configurator/sidebar.html +6 -6
- package/index.cjs +271 -6
- package/index.d.ts +28 -2
- package/index.js +271 -6
- package/package.json +1 -1
- package/configurator/_app/immutable/chunks/Bi4PZjwD.js +0 -210
- package/configurator/_app/immutable/entry/start.D-_N2KA9.js +0 -1
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { WindowLike } from 'dompurify';
|
|
4
4
|
import { MarkedExtension } from 'marked';
|
|
5
|
+
import { SSE } from 'sse.js';
|
|
5
6
|
|
|
6
7
|
export interface UsedLink {
|
|
7
8
|
url: string;
|
|
@@ -6636,6 +6637,12 @@ export declare const completeChatConfigSchema: z.ZodObject<{
|
|
|
6636
6637
|
renderKatex: z.ZodOptional<z.ZodBoolean>;
|
|
6637
6638
|
/** When set, changing the language will change the url path to /[selected language locale] */
|
|
6638
6639
|
reflectLanguageInPath: z.ZodOptional<z.ZodBoolean>;
|
|
6640
|
+
/** When enabled, sends the current page referrer and domain to the backend with each question */
|
|
6641
|
+
sendReferrer: z.ZodOptional<z.ZodEnum<[
|
|
6642
|
+
"all",
|
|
6643
|
+
"own",
|
|
6644
|
+
"none"
|
|
6645
|
+
]>>;
|
|
6639
6646
|
}, "strip", z.ZodTypeAny, {
|
|
6640
6647
|
showPredefinedQuestions: boolean;
|
|
6641
6648
|
showOverallFeedbackButton: boolean;
|
|
@@ -7087,6 +7094,7 @@ export declare const completeChatConfigSchema: z.ZodObject<{
|
|
|
7087
7094
|
addQueryToUrlParams?: boolean | undefined;
|
|
7088
7095
|
renderKatex?: boolean | undefined;
|
|
7089
7096
|
reflectLanguageInPath?: boolean | undefined;
|
|
7097
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
7090
7098
|
}, {
|
|
7091
7099
|
showPredefinedQuestions: boolean;
|
|
7092
7100
|
showOverallFeedbackButton: boolean;
|
|
@@ -7538,6 +7546,7 @@ export declare const completeChatConfigSchema: z.ZodObject<{
|
|
|
7538
7546
|
addQueryToUrlParams?: boolean | undefined;
|
|
7539
7547
|
renderKatex?: boolean | undefined;
|
|
7540
7548
|
reflectLanguageInPath?: boolean | undefined;
|
|
7549
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
7541
7550
|
}>;
|
|
7542
7551
|
export declare const chatConfigSchema: z.ZodObject<{
|
|
7543
7552
|
showPredefinedQuestions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -11919,6 +11928,11 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
11919
11928
|
addQueryToUrlParams: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
11920
11929
|
renderKatex: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
11921
11930
|
reflectLanguageInPath: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
11931
|
+
sendReferrer: z.ZodOptional<z.ZodOptional<z.ZodEnum<[
|
|
11932
|
+
"all",
|
|
11933
|
+
"own",
|
|
11934
|
+
"none"
|
|
11935
|
+
]>>>;
|
|
11922
11936
|
}, "strip", z.ZodTypeAny, {
|
|
11923
11937
|
menu?: Partial<Record<"en" | "de" | "fr" | "it", {
|
|
11924
11938
|
url: string;
|
|
@@ -12370,6 +12384,7 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
12370
12384
|
addQueryToUrlParams?: boolean | undefined;
|
|
12371
12385
|
renderKatex?: boolean | undefined;
|
|
12372
12386
|
reflectLanguageInPath?: boolean | undefined;
|
|
12387
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
12373
12388
|
}, {
|
|
12374
12389
|
menu?: Partial<Record<"en" | "de" | "fr" | "it", {
|
|
12375
12390
|
url: string;
|
|
@@ -12821,6 +12836,7 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
12821
12836
|
addQueryToUrlParams?: boolean | undefined;
|
|
12822
12837
|
renderKatex?: boolean | undefined;
|
|
12823
12838
|
reflectLanguageInPath?: boolean | undefined;
|
|
12839
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
12824
12840
|
}>;
|
|
12825
12841
|
export declare const chatConfigSchemaWithLegacyThemeName: z.ZodIntersection<z.ZodObject<{
|
|
12826
12842
|
showPredefinedQuestions: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -17202,6 +17218,11 @@ export declare const chatConfigSchemaWithLegacyThemeName: z.ZodIntersection<z.Zo
|
|
|
17202
17218
|
addQueryToUrlParams: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
17203
17219
|
renderKatex: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
17204
17220
|
reflectLanguageInPath: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
17221
|
+
sendReferrer: z.ZodOptional<z.ZodOptional<z.ZodEnum<[
|
|
17222
|
+
"all",
|
|
17223
|
+
"own",
|
|
17224
|
+
"none"
|
|
17225
|
+
]>>>;
|
|
17205
17226
|
}, "strip", z.ZodTypeAny, {
|
|
17206
17227
|
menu?: Partial<Record<"en" | "de" | "fr" | "it", {
|
|
17207
17228
|
url: string;
|
|
@@ -17653,6 +17674,7 @@ export declare const chatConfigSchemaWithLegacyThemeName: z.ZodIntersection<z.Zo
|
|
|
17653
17674
|
addQueryToUrlParams?: boolean | undefined;
|
|
17654
17675
|
renderKatex?: boolean | undefined;
|
|
17655
17676
|
reflectLanguageInPath?: boolean | undefined;
|
|
17677
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
17656
17678
|
}, {
|
|
17657
17679
|
menu?: Partial<Record<"en" | "de" | "fr" | "it", {
|
|
17658
17680
|
url: string;
|
|
@@ -18104,6 +18126,7 @@ export declare const chatConfigSchemaWithLegacyThemeName: z.ZodIntersection<z.Zo
|
|
|
18104
18126
|
addQueryToUrlParams?: boolean | undefined;
|
|
18105
18127
|
renderKatex?: boolean | undefined;
|
|
18106
18128
|
reflectLanguageInPath?: boolean | undefined;
|
|
18129
|
+
sendReferrer?: "all" | "own" | "none" | undefined;
|
|
18107
18130
|
}>, z.ZodObject<{
|
|
18108
18131
|
theme: z.ZodOptional<z.ZodObject<{
|
|
18109
18132
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -18140,13 +18163,15 @@ export type SseSubscriptionOptions = {
|
|
|
18140
18163
|
onMessage: (data: unknown) => void;
|
|
18141
18164
|
onError: (event: Event) => void;
|
|
18142
18165
|
onClose: () => void;
|
|
18143
|
-
EventSource?: Constructor<
|
|
18166
|
+
EventSource?: Constructor<SSE>;
|
|
18167
|
+
apiKey?: string;
|
|
18144
18168
|
};
|
|
18145
18169
|
declare class SseSubscription {
|
|
18146
18170
|
private options;
|
|
18171
|
+
private payload?;
|
|
18147
18172
|
private readonly eventSource;
|
|
18148
18173
|
private triggeredOnClose;
|
|
18149
|
-
constructor(url: string, options: SseSubscriptionOptions);
|
|
18174
|
+
constructor(url: string, options: SseSubscriptionOptions, payload?: Record<string, string> | undefined);
|
|
18150
18175
|
isClosed(): boolean;
|
|
18151
18176
|
close(): void;
|
|
18152
18177
|
}
|
|
@@ -18210,6 +18235,7 @@ export type ChatOptions = {
|
|
|
18210
18235
|
lang?: string;
|
|
18211
18236
|
features?: string[];
|
|
18212
18237
|
version?: string;
|
|
18238
|
+
referrer?: string;
|
|
18213
18239
|
onError?: OnError;
|
|
18214
18240
|
onMessage?: (message: SseMessageV2) => void;
|
|
18215
18241
|
};
|
package/index.js
CHANGED
|
@@ -10644,7 +10644,8 @@ var completeChatConfigSchema = exports_external.object({
|
|
|
10644
10644
|
buttonHref: exports_external.string().optional(),
|
|
10645
10645
|
addQueryToUrlParams: exports_external.boolean().optional(),
|
|
10646
10646
|
renderKatex: exports_external.boolean().optional(),
|
|
10647
|
-
reflectLanguageInPath: exports_external.boolean().optional()
|
|
10647
|
+
reflectLanguageInPath: exports_external.boolean().optional(),
|
|
10648
|
+
sendReferrer: exports_external.enum(["all", "own", "none"]).optional()
|
|
10648
10649
|
});
|
|
10649
10650
|
var chatConfigSchema = completeChatConfigSchema.partial();
|
|
10650
10651
|
var chatConfigSchemaWithLegacyThemeName = chatConfigSchema.and(exports_external.object({
|
|
@@ -10712,14 +10713,277 @@ var getUserData = async (restClient) => {
|
|
|
10712
10713
|
}
|
|
10713
10714
|
};
|
|
10714
10715
|
|
|
10716
|
+
// node_modules/.pnpm/sse.js@2.7.2/node_modules/sse.js/lib/sse.js
|
|
10717
|
+
var exports_sse = {};
|
|
10718
|
+
__export(exports_sse, {
|
|
10719
|
+
SSE: () => SSE
|
|
10720
|
+
});
|
|
10721
|
+
var SSE = function(url, options2) {
|
|
10722
|
+
if (!(this instanceof SSE)) {
|
|
10723
|
+
return new SSE(url, options2);
|
|
10724
|
+
}
|
|
10725
|
+
this.url = url;
|
|
10726
|
+
options2 = options2 || {};
|
|
10727
|
+
this.headers = options2.headers || {};
|
|
10728
|
+
this.payload = options2.payload !== undefined ? options2.payload : "";
|
|
10729
|
+
this.method = options2.method || this.payload && "POST" || "GET";
|
|
10730
|
+
this.withCredentials = !!options2.withCredentials;
|
|
10731
|
+
this.debug = !!options2.debug;
|
|
10732
|
+
this.autoReconnect = options2.autoReconnect !== undefined ? options2.autoReconnect : false;
|
|
10733
|
+
this.reconnectDelay = options2.reconnectDelay !== undefined ? options2.reconnectDelay : 3000;
|
|
10734
|
+
this.maxRetries = options2.maxRetries !== undefined ? options2.maxRetries : null;
|
|
10735
|
+
this.retryCount = 0;
|
|
10736
|
+
this.reconnectTimer = null;
|
|
10737
|
+
this.useLastEventId = options2.useLastEventId !== undefined ? options2.useLastEventId : true;
|
|
10738
|
+
this.FIELD_SEPARATOR = ":";
|
|
10739
|
+
this.listeners = {};
|
|
10740
|
+
this.xhr = null;
|
|
10741
|
+
this.readyState = SSE.INITIALIZING;
|
|
10742
|
+
this.progress = 0;
|
|
10743
|
+
this.chunk = "";
|
|
10744
|
+
this.lastEventId = "";
|
|
10745
|
+
this.addEventListener = function(type, listener) {
|
|
10746
|
+
if (this.listeners[type] === undefined) {
|
|
10747
|
+
this.listeners[type] = [];
|
|
10748
|
+
}
|
|
10749
|
+
if (this.listeners[type].indexOf(listener) === -1) {
|
|
10750
|
+
this.listeners[type].push(listener);
|
|
10751
|
+
}
|
|
10752
|
+
};
|
|
10753
|
+
this.removeEventListener = function(type, listener) {
|
|
10754
|
+
if (this.listeners[type] === undefined) {
|
|
10755
|
+
return;
|
|
10756
|
+
}
|
|
10757
|
+
const filtered = [];
|
|
10758
|
+
this.listeners[type].forEach(function(element2) {
|
|
10759
|
+
if (element2 !== listener) {
|
|
10760
|
+
filtered.push(element2);
|
|
10761
|
+
}
|
|
10762
|
+
});
|
|
10763
|
+
if (filtered.length === 0) {
|
|
10764
|
+
delete this.listeners[type];
|
|
10765
|
+
} else {
|
|
10766
|
+
this.listeners[type] = filtered;
|
|
10767
|
+
}
|
|
10768
|
+
};
|
|
10769
|
+
this.dispatchEvent = function(e) {
|
|
10770
|
+
if (!e) {
|
|
10771
|
+
return true;
|
|
10772
|
+
}
|
|
10773
|
+
if (this.debug) {
|
|
10774
|
+
console.debug(e);
|
|
10775
|
+
}
|
|
10776
|
+
e.source = this;
|
|
10777
|
+
const onHandler = "on" + e.type;
|
|
10778
|
+
if (this.hasOwnProperty(onHandler)) {
|
|
10779
|
+
this[onHandler].call(this, e);
|
|
10780
|
+
if (e.defaultPrevented) {
|
|
10781
|
+
return false;
|
|
10782
|
+
}
|
|
10783
|
+
}
|
|
10784
|
+
if (this.listeners[e.type]) {
|
|
10785
|
+
return this.listeners[e.type].every(function(callback) {
|
|
10786
|
+
callback(e);
|
|
10787
|
+
return !e.defaultPrevented;
|
|
10788
|
+
});
|
|
10789
|
+
}
|
|
10790
|
+
return true;
|
|
10791
|
+
};
|
|
10792
|
+
this._markClosed = function() {
|
|
10793
|
+
this.xhr = null;
|
|
10794
|
+
this.progress = 0;
|
|
10795
|
+
this.chunk = "";
|
|
10796
|
+
this._setReadyState(SSE.CLOSED);
|
|
10797
|
+
if (this.autoReconnect) {
|
|
10798
|
+
if (this.maxRetries !== null && this.retryCount >= this.maxRetries) {
|
|
10799
|
+
if (this.debug) {
|
|
10800
|
+
console.debug(`SSE max retries (${this.maxRetries}) reached, stopping reconnection attempts`);
|
|
10801
|
+
}
|
|
10802
|
+
this.autoReconnect = false;
|
|
10803
|
+
this.close();
|
|
10804
|
+
return;
|
|
10805
|
+
}
|
|
10806
|
+
if (this.reconnectTimer) {
|
|
10807
|
+
clearTimeout(this.reconnectTimer);
|
|
10808
|
+
}
|
|
10809
|
+
if (this.debug) {
|
|
10810
|
+
console.debug(`SSE will attempt to reconnect in ${this.reconnectDelay}ms (attempt ${this.retryCount + 1}${this.maxRetries ? "/" + this.maxRetries : ""})`);
|
|
10811
|
+
}
|
|
10812
|
+
this.reconnectTimer = setTimeout(() => {
|
|
10813
|
+
this.reconnectTimer = null;
|
|
10814
|
+
this.retryCount++;
|
|
10815
|
+
this.stream();
|
|
10816
|
+
}, this.reconnectDelay);
|
|
10817
|
+
}
|
|
10818
|
+
};
|
|
10819
|
+
this._setReadyState = function(state2) {
|
|
10820
|
+
const event2 = new CustomEvent("readystatechange");
|
|
10821
|
+
event2.readyState = state2;
|
|
10822
|
+
this.readyState = state2;
|
|
10823
|
+
this.dispatchEvent(event2);
|
|
10824
|
+
};
|
|
10825
|
+
this._onStreamFailure = function(e) {
|
|
10826
|
+
const event2 = new CustomEvent("error");
|
|
10827
|
+
event2.responseCode = e.currentTarget.status;
|
|
10828
|
+
event2.data = e.currentTarget.response;
|
|
10829
|
+
this.dispatchEvent(event2);
|
|
10830
|
+
this._markClosed();
|
|
10831
|
+
};
|
|
10832
|
+
this._onStreamAbort = function() {
|
|
10833
|
+
this.dispatchEvent(new CustomEvent("abort"));
|
|
10834
|
+
this._markClosed();
|
|
10835
|
+
};
|
|
10836
|
+
this._onStreamProgress = function(e) {
|
|
10837
|
+
if (!this.xhr) {
|
|
10838
|
+
return;
|
|
10839
|
+
}
|
|
10840
|
+
if (this.xhr.status < 200 || this.xhr.status >= 300) {
|
|
10841
|
+
this._onStreamFailure(e);
|
|
10842
|
+
return;
|
|
10843
|
+
}
|
|
10844
|
+
this.retryCount = 0;
|
|
10845
|
+
const data = this.xhr.responseText.substring(this.progress);
|
|
10846
|
+
this.progress += data.length;
|
|
10847
|
+
const parts = (this.chunk + data).split(/(\r\n\r\n|\r\r|\n\n)/g);
|
|
10848
|
+
const lastPart = parts.pop();
|
|
10849
|
+
parts.forEach(function(part) {
|
|
10850
|
+
if (part.trim().length > 0) {
|
|
10851
|
+
this.dispatchEvent(this._parseEventChunk(part));
|
|
10852
|
+
}
|
|
10853
|
+
}.bind(this));
|
|
10854
|
+
this.chunk = lastPart;
|
|
10855
|
+
};
|
|
10856
|
+
this._onStreamLoaded = function(e) {
|
|
10857
|
+
this._onStreamProgress(e);
|
|
10858
|
+
this.dispatchEvent(this._parseEventChunk(this.chunk));
|
|
10859
|
+
this.chunk = "";
|
|
10860
|
+
this._markClosed();
|
|
10861
|
+
};
|
|
10862
|
+
this._parseEventChunk = function(chunk) {
|
|
10863
|
+
if (!chunk || chunk.length === 0) {
|
|
10864
|
+
return null;
|
|
10865
|
+
}
|
|
10866
|
+
if (this.debug) {
|
|
10867
|
+
console.debug(chunk);
|
|
10868
|
+
}
|
|
10869
|
+
const e = { id: null, retry: null, data: null, event: null };
|
|
10870
|
+
chunk.split(/\n|\r\n|\r/).forEach(function(line) {
|
|
10871
|
+
const index2 = line.indexOf(this.FIELD_SEPARATOR);
|
|
10872
|
+
let field, value;
|
|
10873
|
+
if (index2 > 0) {
|
|
10874
|
+
const skip = line[index2 + 1] === " " ? 2 : 1;
|
|
10875
|
+
field = line.substring(0, index2);
|
|
10876
|
+
value = line.substring(index2 + skip);
|
|
10877
|
+
} else if (index2 < 0) {
|
|
10878
|
+
field = line;
|
|
10879
|
+
value = "";
|
|
10880
|
+
} else {
|
|
10881
|
+
return;
|
|
10882
|
+
}
|
|
10883
|
+
if (!(field in e)) {
|
|
10884
|
+
return;
|
|
10885
|
+
}
|
|
10886
|
+
if (field === "data" && e[field] !== null) {
|
|
10887
|
+
e["data"] += `
|
|
10888
|
+
` + value;
|
|
10889
|
+
} else {
|
|
10890
|
+
e[field] = value;
|
|
10891
|
+
}
|
|
10892
|
+
}.bind(this));
|
|
10893
|
+
if (e.data === null) {
|
|
10894
|
+
return null;
|
|
10895
|
+
}
|
|
10896
|
+
if (e.id !== null) {
|
|
10897
|
+
this.lastEventId = e.id;
|
|
10898
|
+
}
|
|
10899
|
+
const event2 = new CustomEvent(e.event || "message");
|
|
10900
|
+
event2.id = e.id;
|
|
10901
|
+
event2.data = e.data || "";
|
|
10902
|
+
event2.lastEventId = this.lastEventId;
|
|
10903
|
+
return event2;
|
|
10904
|
+
};
|
|
10905
|
+
this._onReadyStateChange = function() {
|
|
10906
|
+
if (!this.xhr) {
|
|
10907
|
+
return;
|
|
10908
|
+
}
|
|
10909
|
+
if (this.xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
10910
|
+
const headers = {};
|
|
10911
|
+
const headerPairs = this.xhr.getAllResponseHeaders().trim().split(`\r
|
|
10912
|
+
`);
|
|
10913
|
+
for (const headerPair of headerPairs) {
|
|
10914
|
+
const [key2, ...valueParts] = headerPair.split(":");
|
|
10915
|
+
const value = valueParts.join(":").trim();
|
|
10916
|
+
headers[key2.trim().toLowerCase()] = headers[key2.trim().toLowerCase()] || [];
|
|
10917
|
+
headers[key2.trim().toLowerCase()].push(value);
|
|
10918
|
+
}
|
|
10919
|
+
const event2 = new CustomEvent("open");
|
|
10920
|
+
event2.responseCode = this.xhr.status;
|
|
10921
|
+
event2.headers = headers;
|
|
10922
|
+
this.dispatchEvent(event2);
|
|
10923
|
+
this._setReadyState(SSE.OPEN);
|
|
10924
|
+
}
|
|
10925
|
+
};
|
|
10926
|
+
this.stream = function() {
|
|
10927
|
+
if (this.xhr) {
|
|
10928
|
+
return;
|
|
10929
|
+
}
|
|
10930
|
+
this._setReadyState(SSE.CONNECTING);
|
|
10931
|
+
this.xhr = new XMLHttpRequest;
|
|
10932
|
+
this.xhr.addEventListener("progress", this._onStreamProgress.bind(this));
|
|
10933
|
+
this.xhr.addEventListener("load", this._onStreamLoaded.bind(this));
|
|
10934
|
+
this.xhr.addEventListener("readystatechange", this._onReadyStateChange.bind(this));
|
|
10935
|
+
this.xhr.addEventListener("error", this._onStreamFailure.bind(this));
|
|
10936
|
+
this.xhr.addEventListener("abort", this._onStreamAbort.bind(this));
|
|
10937
|
+
this.xhr.open(this.method, this.url);
|
|
10938
|
+
for (let header in this.headers) {
|
|
10939
|
+
this.xhr.setRequestHeader(header, this.headers[header]);
|
|
10940
|
+
}
|
|
10941
|
+
if (this.useLastEventId && this.lastEventId.length > 0) {
|
|
10942
|
+
this.xhr.setRequestHeader("Last-Event-ID", this.lastEventId);
|
|
10943
|
+
}
|
|
10944
|
+
this.xhr.withCredentials = this.withCredentials;
|
|
10945
|
+
this.xhr.send(this.payload);
|
|
10946
|
+
};
|
|
10947
|
+
this.close = function() {
|
|
10948
|
+
if (this.readyState === SSE.CLOSED) {
|
|
10949
|
+
return;
|
|
10950
|
+
}
|
|
10951
|
+
if (this.reconnectTimer) {
|
|
10952
|
+
clearTimeout(this.reconnectTimer);
|
|
10953
|
+
this.reconnectTimer = null;
|
|
10954
|
+
}
|
|
10955
|
+
this.autoReconnect = false;
|
|
10956
|
+
this.xhr.abort();
|
|
10957
|
+
};
|
|
10958
|
+
if (options2.start === undefined || options2.start) {
|
|
10959
|
+
this.stream();
|
|
10960
|
+
}
|
|
10961
|
+
};
|
|
10962
|
+
SSE.INITIALIZING = -1;
|
|
10963
|
+
SSE.CONNECTING = 0;
|
|
10964
|
+
SSE.OPEN = 1;
|
|
10965
|
+
SSE.CLOSED = 2;
|
|
10966
|
+
if (typeof exports_sse !== "undefined") {
|
|
10967
|
+
exports_sse.SSE = SSE;
|
|
10968
|
+
}
|
|
10969
|
+
|
|
10715
10970
|
// src/lib/client/api/sse-subscription.ts
|
|
10716
10971
|
class SseSubscription {
|
|
10717
10972
|
options;
|
|
10973
|
+
payload;
|
|
10718
10974
|
eventSource;
|
|
10719
10975
|
triggeredOnClose = false;
|
|
10720
|
-
constructor(url, options2) {
|
|
10976
|
+
constructor(url, options2, payload) {
|
|
10721
10977
|
this.options = options2;
|
|
10722
|
-
this.
|
|
10978
|
+
this.payload = payload;
|
|
10979
|
+
const sseoptions = { headers: { "content-type": "application/json" } };
|
|
10980
|
+
if (payload) {
|
|
10981
|
+
sseoptions.payload = JSON.stringify(payload);
|
|
10982
|
+
}
|
|
10983
|
+
if (options2.apiKey) {
|
|
10984
|
+
sseoptions.headers["api-key"] = options2.apiKey;
|
|
10985
|
+
}
|
|
10986
|
+
this.eventSource = new (options2.EventSource ?? SSE)(url, sseoptions);
|
|
10723
10987
|
this.eventSource.onmessage = (event2) => {
|
|
10724
10988
|
try {
|
|
10725
10989
|
const data = JSON.parse(event2.data);
|
|
@@ -10770,10 +11034,10 @@ class RestClient {
|
|
|
10770
11034
|
return this.options.speechRecognitionApiKey;
|
|
10771
11035
|
}
|
|
10772
11036
|
async subscribeSse(path, params = {}, options2) {
|
|
10773
|
-
const
|
|
11037
|
+
const payload = removeUndefinedValues(params);
|
|
10774
11038
|
if (this.options.apiKey)
|
|
10775
|
-
|
|
10776
|
-
return new SseSubscription(`${this.options.apiUrl}${path}
|
|
11039
|
+
options2.apiKey = this.options.apiKey;
|
|
11040
|
+
return new SseSubscription(`${this.options.apiUrl}${path}`, options2, payload);
|
|
10777
11041
|
}
|
|
10778
11042
|
async fetchData(path, validator, params = {}, options2 = {}) {
|
|
10779
11043
|
const url = `${this.options.apiUrl}${path}?${new URLSearchParams(removeUndefinedValues(params)).toString()}`;
|
|
@@ -11003,6 +11267,7 @@ class LiipGPTClientPrimitive {
|
|
|
11003
11267
|
lang: options2.lang,
|
|
11004
11268
|
model: options2.model,
|
|
11005
11269
|
feature: options2.features?.join(","),
|
|
11270
|
+
referrer: options2.referrer,
|
|
11006
11271
|
chat: "true",
|
|
11007
11272
|
version: "2"
|
|
11008
11273
|
}, {
|