@clikvn/agent-widget-embedded 0.0.10-dev → 0.0.12-dev

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.
Files changed (73) hide show
  1. package/dist/commons/constants/variables.d.ts +4 -0
  2. package/dist/commons/constants/variables.d.ts.map +1 -1
  3. package/dist/components/Chat/Icons.d.ts +19 -1
  4. package/dist/components/Chat/Icons.d.ts.map +1 -1
  5. package/dist/components/Chat/Message.d.ts.map +1 -1
  6. package/dist/components/Chat/MultimodalInput.d.ts +1 -1
  7. package/dist/components/Chat/MultimodalInput.d.ts.map +1 -1
  8. package/dist/components/Chat/SuggestedActions.d.ts +12 -0
  9. package/dist/components/Chat/SuggestedActions.d.ts.map +1 -0
  10. package/dist/features/AgentWidget/index.d.ts +8 -2
  11. package/dist/features/AgentWidget/index.d.ts.map +1 -1
  12. package/dist/hooks/useConfiguration.d.ts +8 -1
  13. package/dist/hooks/useConfiguration.d.ts.map +1 -1
  14. package/dist/index.html +45 -44
  15. package/dist/types/common.type.d.ts +6 -0
  16. package/dist/types/common.type.d.ts.map +1 -1
  17. package/dist/web.js +1 -1
  18. package/package.json +3 -2
  19. package/.eslintrc +0 -34
  20. package/.prettierrc +0 -8
  21. package/dist/components/Chat/AudioRecording.d.ts +0 -9
  22. package/dist/components/Chat/AudioRecording.d.ts.map +0 -1
  23. package/dist/hooks/useConnection.d.ts +0 -15
  24. package/dist/hooks/useConnection.d.ts.map +0 -1
  25. package/dist/services/user.service.d.ts +0 -3
  26. package/dist/services/user.service.d.ts.map +0 -1
  27. package/dist/types/agentType.d.ts +0 -11
  28. package/dist/types/agentType.d.ts.map +0 -1
  29. package/src/assets/common.css +0 -148
  30. package/src/assets/tailwindcss.css +0 -3
  31. package/src/commons/constants/index.ts +0 -1
  32. package/src/commons/constants/variables.ts +0 -20
  33. package/src/components/Agent/index.tsx +0 -14
  34. package/src/components/Chat/AudioPlayer.tsx +0 -44
  35. package/src/components/Chat/Chat.tsx +0 -91
  36. package/src/components/Chat/Icons.tsx +0 -930
  37. package/src/components/Chat/Markdown.tsx +0 -335
  38. package/src/components/Chat/Message.tsx +0 -191
  39. package/src/components/Chat/MultimodalInput.tsx +0 -479
  40. package/src/components/Chat/Overview.tsx +0 -46
  41. package/src/components/Chat/PreviewAttachment.tsx +0 -46
  42. package/src/components/Chat/ui/Button.tsx +0 -55
  43. package/src/components/Chat/ui/Textarea.tsx +0 -23
  44. package/src/constants.ts +0 -1
  45. package/src/env.d.ts +0 -10
  46. package/src/features/AgentWidget/index.tsx +0 -57
  47. package/src/global.d.ts +0 -1
  48. package/src/hooks/useAudioRecording.ts +0 -50
  49. package/src/hooks/useChat.ts +0 -262
  50. package/src/hooks/useChatData.tsx +0 -68
  51. package/src/hooks/useConfiguration.tsx +0 -56
  52. package/src/hooks/useScrollToBottom.ts +0 -31
  53. package/src/index.ts +0 -1
  54. package/src/models/FlowiseClient.ts +0 -103
  55. package/src/models.ts +0 -1
  56. package/src/register.tsx +0 -85
  57. package/src/services/apis.ts +0 -12
  58. package/src/services/bot.service.ts +0 -15
  59. package/src/services/chat.service.ts +0 -199
  60. package/src/types/bot.type.ts +0 -10
  61. package/src/types/chat.type.ts +0 -11
  62. package/src/types/common.type.ts +0 -17
  63. package/src/types/flowise.type.ts +0 -108
  64. package/src/types/user.type.ts +0 -15
  65. package/src/types.ts +0 -0
  66. package/src/utils/audioRecording.ts +0 -371
  67. package/src/utils/commonUtils.ts +0 -47
  68. package/src/utils/functionUtils.ts +0 -17
  69. package/src/utils/requestUtils.ts +0 -113
  70. package/src/utils/streamUtils.ts +0 -18
  71. package/src/web.ts +0 -6
  72. package/src/window.ts +0 -43
  73. package/tsconfig.json +0 -24
@@ -1,57 +0,0 @@
1
- import { FC } from 'react';
2
- import { ConfigurationProvider } from '../../hooks/useConfiguration';
3
- import { EVENT_TYPE } from '../../models';
4
- import Agent from '../../components/Agent';
5
- import { ChatDataProvider } from '../../hooks/useChatData';
6
- import styles from '../../assets/tailwindcss.css';
7
- import commonStyles from '../../assets/common.css';
8
- import { SuggestionType } from '../../types/common.type';
9
-
10
- export type AgentWidgetType = {
11
- apiHost: string;
12
- agentId: string;
13
- overrideConfig?: {
14
- chatId?: string | undefined;
15
- overrideConfig?: Record<string, unknown>;
16
- suggestedActions?: SuggestionType[];
17
- } & Record<string, unknown>;
18
- theme?: {
19
- avatar?: string;
20
- input?: {
21
- placeholder?: string;
22
- };
23
- overview?: {
24
- title: string;
25
- description?: string;
26
- };
27
- } & Record<string, unknown>;
28
- listeners?: Record<EVENT_TYPE, (props: any) => void>;
29
- };
30
- const AgentWidget: FC<AgentWidgetType> = (props: AgentWidgetType) => {
31
- return (
32
- <div className="w-full h-full">
33
- <style>{styles}</style>
34
- <style>{commonStyles}</style>
35
- <ConfigurationProvider
36
- config={{
37
- apiHost: props.apiHost,
38
- agentId: props.agentId,
39
- overrideConfig: props.overrideConfig?.overrideConfig,
40
- theme: props.theme,
41
- }}
42
- >
43
- <ChatDataProvider
44
- data={{
45
- chatId: props.overrideConfig?.chatId,
46
- suggestedActions: props.overrideConfig?.suggestedActions,
47
- listeners: props.listeners,
48
- }}
49
- >
50
- <Agent />
51
- </ChatDataProvider>
52
- </ConfigurationProvider>
53
- </div>
54
- );
55
- };
56
-
57
- export default AgentWidget;
package/src/global.d.ts DELETED
@@ -1 +0,0 @@
1
- declare module '*.css';
@@ -1,50 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import {
3
- cancelAudioRecording,
4
- startAudioRecording,
5
- stopAudioRecording,
6
- } from '../utils/audioRecording';
7
-
8
- export const useAudioRecording = () => {
9
- const [elapsedTime, setElapsedTime] = useState('00:00');
10
- const [recordingNotSupported, setRecordingNotSupported] = useState(false);
11
- const [isLoadingRecording, setIsLoadingRecording] = useState(false);
12
- const [isRecording, setIsRecording] = useState(false);
13
-
14
- useEffect(() => {
15
- if (isRecording) {
16
- onRecordingStarted();
17
- }
18
- }, [isRecording]);
19
- const onRecordingStarted = () => {
20
- setIsRecording(true);
21
- setIsLoadingRecording(false);
22
- startAudioRecording(
23
- setIsRecording,
24
- setRecordingNotSupported,
25
- setElapsedTime
26
- );
27
- };
28
-
29
- const onRecordingCancelled = () => {
30
- if (!recordingNotSupported) cancelAudioRecording();
31
- setIsRecording(false);
32
- setRecordingNotSupported(false);
33
- };
34
-
35
- const onRecordingStopped = (onStop: null | ((blob: Blob) => void)) => {
36
- setIsLoadingRecording(true);
37
- stopAudioRecording(onStop);
38
- };
39
-
40
- return {
41
- elapsedTime,
42
- recordingNotSupported,
43
- isLoadingRecording,
44
- isRecording,
45
- setIsRecording,
46
- onRecordingCancelled,
47
- onRecordingStopped,
48
- onRecordingStarted,
49
- };
50
- };
@@ -1,262 +0,0 @@
1
- import useSWR from 'swr';
2
- import { useCallback, useEffect, useRef, useState } from 'react';
3
- import { StreamResponse } from '../models/FlowiseClient';
4
- import { getSuggestions, predict } from '../services/chat.service';
5
- import {
6
- ChatMessageMetadataType,
7
- ChatMessageType,
8
- IFileUpload,
9
- PredictionData,
10
- SourceDocument,
11
- ToolUsage,
12
- } from '../types/flowise.type';
13
- import { generateUUID } from '../utils/commonUtils';
14
- import { getBot } from '../services/bot.service';
15
- import { BotType } from '../types/bot.type';
16
- import { useConfiguration } from './useConfiguration';
17
- import { SuggestionType } from 'types/common.type';
18
-
19
- type PropsType = {
20
- id?: string;
21
- agentId?: string;
22
- initialMessages: ChatMessageType[];
23
- initialInput?: string;
24
- };
25
-
26
- type ReturnType = {
27
- messages?: ChatMessageType[];
28
- setMessages: (messages: ChatMessageType[]) => void;
29
- handleSubmit: (event?: { preventDefault?: () => void }) => void;
30
- input?: string;
31
- setInput: (input: string) => void;
32
- isLoading: boolean;
33
- stop: () => void;
34
- chatId: string;
35
- append: (message: ChatMessageType) => Promise<void>;
36
- bot: BotType | null;
37
- enableTTS: boolean;
38
- setEnableTTS: (value: boolean) => void;
39
- suggestions: SuggestionType[]
40
- };
41
-
42
- export const useChat = (props: PropsType): ReturnType => {
43
- const { id, initialMessages, initialInput, agentId } = props;
44
- const { apiHost, overrideConfig, theme } = useConfiguration();
45
-
46
- const idKey = id ?? generateUUID();
47
- const chatIdRef = useRef<string>(idKey);
48
- const [chatId, setChatId] = useState(idKey);
49
- const [bot, setBot] = useState<BotType | null>(null);
50
- const [enableTTS, setEnableTTS] = useState(false);
51
- const [suggestions, setSuggestions] = useState<SuggestionType[]>([]);
52
-
53
-
54
- const updateChatId = (uuid: string) => {
55
- chatIdRef.current = uuid;
56
- setChatId(uuid);
57
- };
58
-
59
- useEffect(() => {
60
- if (id) {
61
- updateChatId(id);
62
- }
63
- }, [id]);
64
-
65
- useEffect(() => {
66
- getBot(agentId || 'default', apiHost).then((res) => setBot(res));
67
- }, [agentId, apiHost]);
68
-
69
- useEffect(() => {
70
- if (bot?.id && chatId) {
71
- updateSuggestions(`Agent name: ${bot.name}, Title: ${theme?.overview?.title}`)
72
- }
73
- }, [bot?.id, chatId])
74
-
75
- const updateSuggestions = useCallback(async (question?: string) => {
76
- const resSuggestions = await getSuggestions({ id: chatId, question, apiHost });
77
- setSuggestions(resSuggestions);
78
- }, [setSuggestions, chatId]);
79
-
80
- const processResponseStream = async (
81
- msgs: ChatMessageType[],
82
- req: PredictionData
83
- ) => {
84
- // Do an optimistic update to the chat state to show the updated messages immediately:
85
- mutateMessages(msgs, false);
86
-
87
- const newMessage: ChatMessageType = {
88
- id: generateUUID(),
89
- chatId: chatIdRef.current,
90
- role: 'apiMessage',
91
- content: '',
92
- createdDate: new Date().toISOString(),
93
- };
94
-
95
- const onUpdate = (chunk: StreamResponse) => {
96
- if (chunk?.event === 'token') {
97
- newMessage.content = newMessage.content + (chunk.data as string);
98
- mutateMessages([...msgs, { ...newMessage }]);
99
- } else if (chunk.event == 'usedTools') {
100
- newMessage.usedTools = chunk.data as ToolUsage[];
101
- mutateMessages([...msgs, { ...newMessage }]);
102
- } else if (chunk.event == 'sourceDocuments') {
103
- newMessage.sourceDocuments = chunk.data as SourceDocument[];
104
- mutateMessages([...msgs, { ...newMessage }]);
105
- } else if (chunk.event == 'metadata') {
106
- newMessage.metaData = chunk.data as ChatMessageMetadataType;
107
- const lastMsg = msgs[msgs.length - 1];
108
- if (lastMsg) {
109
- lastMsg.content = newMessage.metaData.question;
110
- }
111
- mutateMessages([...msgs, { ...newMessage }]);
112
- updateSuggestions(`Agent name: ${bot?.name}, Title: ${theme?.overview?.title}`);
113
- } else if (chunk.event == 'audio') {
114
- newMessage.ttsUrl = chunk.data as string;
115
- mutateMessages([...msgs, { ...newMessage }]);
116
- }
117
- };
118
-
119
- return await predict({
120
- req,
121
- apiHost,
122
- onUpdate,
123
- });
124
- };
125
-
126
- // Store a empty array as the initial messages
127
- // (instead of using a default parameter value that gets re-created each time)
128
- // to avoid re-renders:
129
- const [initialMessagesFallback] = useState([]);
130
-
131
- // Store the chat state in SWR, using the chatId as the key to share states.
132
- const { data: messages, mutate: mutateMessages } = useSWR<ChatMessageType[]>(
133
- [chatId, 'messages'],
134
- null,
135
- { fallbackData: initialMessages ?? initialMessagesFallback }
136
- );
137
-
138
- // Keep the latest messages in a ref.
139
- const messagesRef = useRef<ChatMessageType[]>(messages || []);
140
- useEffect(() => {
141
- messagesRef.current = messages || [];
142
- }, [messages]);
143
-
144
- // We store loading state in another hook to sync loading states across hook invocations
145
- const { data: isLoading = false, mutate: mutateLoading } = useSWR<boolean>(
146
- [chatId, 'loading'],
147
- null
148
- );
149
-
150
- // Abort controller to cancel the current API call.
151
- const abortControllerRef = useRef<AbortController | null>(null);
152
-
153
- const triggerRequest = useCallback(
154
- async (msgs: ChatMessageType[], req: PredictionData) => {
155
- try {
156
- mutateLoading(true);
157
-
158
- const abortController = new AbortController();
159
- abortControllerRef.current = abortController;
160
-
161
- await processResponseStream(msgs, req);
162
-
163
- abortControllerRef.current = null;
164
- } catch (err) {
165
- // Ignore abort errors as they are expected.
166
- if ((err as any).name === 'AbortError') {
167
- abortControllerRef.current = null;
168
- return null;
169
- }
170
-
171
- console.error(err);
172
- } finally {
173
- mutateLoading(false);
174
- }
175
- },
176
- [mutateMessages, mutateLoading]
177
- );
178
-
179
- const append = async (message: ChatMessageType) => {
180
- if (!message.content) {
181
- return;
182
- }
183
- const msgs = messagesRef.current.concat({
184
- id: generateUUID(),
185
- chatId: chatIdRef.current,
186
- role: 'userMessage',
187
- content: message.content,
188
- createdDate: new Date().toISOString(),
189
- });
190
-
191
- triggerRequest(msgs, {
192
- chatId: chatIdRef.current,
193
- question: message.content,
194
- chatflowId: bot?.id,
195
- overrideConfig: overrideConfig,
196
- tts: enableTTS,
197
- });
198
- setInput('');
199
- };
200
-
201
- const stop = useCallback(() => {
202
- if (abortControllerRef.current) {
203
- abortControllerRef.current?.abort();
204
- abortControllerRef.current = null;
205
- }
206
- }, []);
207
-
208
- const setMessages = useCallback(
209
- (msgs: ChatMessageType[]) => {
210
- mutateMessages(msgs, false);
211
- messagesRef.current = msgs;
212
- },
213
- [mutateMessages]
214
- );
215
-
216
- // Input state and handlers.
217
- const [input, setInput] = useState(initialInput);
218
-
219
- const handleSubmit = useCallback(
220
- async (event?: { preventDefault?: () => void }, files?: IFileUpload[]) => {
221
- event?.preventDefault?.();
222
-
223
- if (!input && !files) return;
224
-
225
- const msgs = messagesRef.current.concat({
226
- id: generateUUID(),
227
- chatId: chatIdRef.current,
228
- role: 'userMessage',
229
- content: input || '',
230
- createdDate: new Date().toISOString(),
231
- fileUploads: files || [],
232
- });
233
-
234
- triggerRequest(msgs, {
235
- chatId: chatIdRef.current,
236
- question: input || '',
237
- uploads: files || [],
238
- chatflowId: bot?.id,
239
- overrideConfig: overrideConfig,
240
- tts: enableTTS,
241
- });
242
- setInput('');
243
- },
244
- [input, triggerRequest, bot]
245
- );
246
-
247
- return {
248
- messages,
249
- setMessages,
250
- input,
251
- setInput,
252
- isLoading,
253
- handleSubmit,
254
- stop,
255
- chatId,
256
- append,
257
- bot,
258
- enableTTS,
259
- setEnableTTS,
260
- suggestions
261
- };
262
- };
@@ -1,68 +0,0 @@
1
- import React, { createContext, useEffect, useState } from 'react';
2
- import { EVENT_TYPE } from '../models';
3
- import { getChatMessage } from '../services/chat.service';
4
- import { ChatMessageType } from '../types/flowise.type';
5
- import { generateUUID } from '../utils/commonUtils';
6
- import { useConfiguration } from './useConfiguration';
7
- import { SuggestionType } from '../types/common.type';
8
-
9
- type ChatData = {
10
- chatId?: string | undefined;
11
- listeners?: Record<EVENT_TYPE, (props: any) => void>;
12
- initialMessages?: ChatMessageType[];
13
- suggestedActions?: SuggestionType[];
14
- };
15
-
16
- const ChatDataContext = createContext<ChatData | undefined>(undefined);
17
-
18
- export const ChatDataProvider = ({
19
- children,
20
- data,
21
- }: {
22
- children: React.ReactNode;
23
- data: ChatData;
24
- }) => {
25
- const [chatData, setChatData] = useState<ChatData>({
26
- ...data,
27
- chatId: data.chatId || generateUUID(),
28
- });
29
-
30
- const { apiHost } = useConfiguration();
31
-
32
- const fetchHistory = async () => {
33
- if (!chatData?.chatId) {
34
- return;
35
- }
36
-
37
- const initialMessages = await getChatMessage({
38
- chatId: chatData.chatId!,
39
- apiHost,
40
- });
41
- setChatData({
42
- ...chatData,
43
- initialMessages,
44
- });
45
- };
46
-
47
- useEffect(() => {
48
- setChatData({ ...data, chatId: chatData.chatId });
49
- }, [data]);
50
-
51
- useEffect(() => {
52
- fetchHistory();
53
- }, [chatData?.chatId]);
54
-
55
- return (
56
- <ChatDataContext.Provider value={chatData}>
57
- {children}
58
- </ChatDataContext.Provider>
59
- );
60
- };
61
-
62
- export const useChatData = () => {
63
- const context = React.useContext(ChatDataContext);
64
- if (context === undefined) {
65
- throw new Error('useChatData must be used within a ChatDataContext');
66
- }
67
- return context;
68
- };
@@ -1,56 +0,0 @@
1
- import React, { createContext, useEffect, useState } from 'react';
2
-
3
- type ConfigurationData = {
4
- apiHost: string;
5
- agentId: string;
6
- overrideConfig?: Record<string, any>;
7
- theme?: {
8
- avatar?: string;
9
- input?: {
10
- placeholder?: string;
11
- };
12
- overview?: {
13
- title: string;
14
- description?: string;
15
- };
16
- } & Record<string, unknown>;
17
- };
18
-
19
- const ConfigurationContext = createContext<ConfigurationData | undefined>(
20
- undefined
21
- );
22
-
23
- export const ConfigurationProvider = ({
24
- children,
25
- config,
26
- }: {
27
- children: React.ReactNode;
28
- config: ConfigurationData;
29
- }) => {
30
- const [configuration, setConfiguration] = useState<ConfigurationData>({
31
- ...config,
32
- });
33
-
34
- useEffect(() => {
35
- if (!config.apiHost) {
36
- throw new Error('apiHost is required');
37
- }
38
- setConfiguration(config);
39
- }, [config]);
40
-
41
- return (
42
- <ConfigurationContext.Provider value={configuration}>
43
- {children}
44
- </ConfigurationContext.Provider>
45
- );
46
- };
47
-
48
- export const useConfiguration = () => {
49
- const context = React.useContext(ConfigurationContext);
50
- if (context === undefined) {
51
- throw new Error(
52
- 'useConfiguration must be used within a ConfigurationProvider'
53
- );
54
- }
55
- return context;
56
- };
@@ -1,31 +0,0 @@
1
- import { type RefObject, useEffect, useRef } from 'react';
2
-
3
- export function useScrollToBottom<T extends HTMLElement>(): [
4
- RefObject<T>,
5
- RefObject<T>,
6
- ] {
7
- const containerRef = useRef<T>(null);
8
- const endRef = useRef<T>(null);
9
-
10
- useEffect(() => {
11
- const container = containerRef.current;
12
- const end = endRef.current;
13
-
14
- if (container && end) {
15
- const observer = new MutationObserver(() => {
16
- end.scrollIntoView({ behavior: 'instant', block: 'end' });
17
- });
18
-
19
- observer.observe(container, {
20
- childList: true,
21
- subtree: true,
22
- attributes: true,
23
- characterData: true,
24
- });
25
-
26
- return () => observer.disconnect();
27
- }
28
- }, []);
29
-
30
- return [containerRef, endRef];
31
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export type { AgentWidgetType } from './features/AgentWidget';
@@ -1,103 +0,0 @@
1
- import { PredictionData } from '../types/flowise.type';
2
- import { BE_API, LANGUAGE_HEADER } from '../commons/constants';
3
-
4
- interface FlowiseClientOptions {
5
- baseUrl: string;
6
- accessToken?: string;
7
- host?: string;
8
- }
9
-
10
- export interface StreamResponse {
11
- event: string;
12
- data: unknown;
13
- }
14
-
15
- type PredictionResponse<T extends PredictionData> = T['streaming'] extends true
16
- ? AsyncGenerator<StreamResponse, void, unknown> // Streaming returns an async generator
17
- : Record<string, any>;
18
-
19
- export default class FlowiseClient {
20
- private baseUrl: string;
21
- private accessToken: string | undefined;
22
- private host: string | undefined;
23
-
24
- constructor(options: FlowiseClientOptions) {
25
- this.baseUrl = options.baseUrl;
26
- this.accessToken = options.accessToken || '';
27
- this.host = options.host || BE_API;
28
- }
29
-
30
- // Method to create a new prediction and handle streaming response
31
- async createPrediction<T extends PredictionData>(
32
- data: T
33
- ): Promise<PredictionResponse<T>> {
34
- const { chatId, streaming = true, language } = data;
35
-
36
- const predictionUrl = `${this.host}${this.baseUrl}/${chatId}`;
37
- let apiLanguage: string = LANGUAGE_HEADER.en;
38
- if (language) {
39
- apiLanguage = LANGUAGE_HEADER[language];
40
- }
41
-
42
- const options: any = {
43
- method: 'POST',
44
- headers: {
45
- 'Content-Type': 'application/json',
46
- },
47
- body: JSON.stringify(data),
48
- language: apiLanguage,
49
- };
50
-
51
- if (this.accessToken) {
52
- options.headers['Authorization'] = `Bearer ${this.accessToken}`;
53
- }
54
-
55
- if (streaming) {
56
- return {
57
- async *[Symbol.asyncIterator]() {
58
- const response = await fetch(predictionUrl, options);
59
-
60
- if (!response.ok) {
61
- throw new Error(`HTTP error! status: ${response.status}`);
62
- }
63
-
64
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
65
- // @ts-ignore
66
- const reader = response.body.getReader();
67
- const decoder = new TextDecoder();
68
- let buffer = '';
69
-
70
- try {
71
- while (true) {
72
- const { done, value } = await reader.read();
73
- if (done) break;
74
-
75
- buffer += decoder.decode(value, { stream: true });
76
- const lines = buffer.split('\n');
77
- buffer = lines.pop() || '';
78
-
79
- for (const line of lines) {
80
- if (line.trim() === '') continue;
81
- if (line.startsWith('data:')) {
82
- const stringifiedJson = line.replace('data:', '');
83
- const event = JSON.parse(stringifiedJson);
84
- yield event;
85
- }
86
- }
87
- }
88
- } finally {
89
- reader.releaseLock();
90
- }
91
- },
92
- } as unknown as Promise<PredictionResponse<T>>;
93
- } else {
94
- try {
95
- const response = await fetch(predictionUrl, options);
96
- const resp = await response.json();
97
- return resp as Promise<PredictionResponse<T>>;
98
- } catch (error) {
99
- throw new Error('Error creating prediction');
100
- }
101
- }
102
- }
103
- }
package/src/models.ts DELETED
@@ -1 +0,0 @@
1
- export type EVENT_TYPE = 'CONNECT' | 'DISCONNECT';