llmasaservice-ui 0.2.13 → 0.2.15
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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +13 -3
- package/dist/index.mjs +13 -3
- package/package.json +1 -1
- package/src/ChatPanel.tsx +16 -2
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,10 @@ interface ChatPanelProps {
|
|
|
23
23
|
url?: string | null;
|
|
24
24
|
scrollToEnd?: boolean;
|
|
25
25
|
prismStyle?: PrismStyle;
|
|
26
|
+
service?: string | null;
|
|
27
|
+
historyChangedCallback?: (history: {
|
|
28
|
+
[prompt: string]: string;
|
|
29
|
+
}) => void;
|
|
26
30
|
}
|
|
27
31
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
28
32
|
inline?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ interface ChatPanelProps {
|
|
|
23
23
|
url?: string | null;
|
|
24
24
|
scrollToEnd?: boolean;
|
|
25
25
|
prismStyle?: PrismStyle;
|
|
26
|
+
service?: string | null;
|
|
27
|
+
historyChangedCallback?: (history: {
|
|
28
|
+
[prompt: string]: string;
|
|
29
|
+
}) => void;
|
|
26
30
|
}
|
|
27
31
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
28
32
|
inline?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,9 @@ var ChatPanel = ({
|
|
|
88
88
|
url = null,
|
|
89
89
|
scrollToEnd = false,
|
|
90
90
|
initialMessage = "",
|
|
91
|
-
prismStyle = theme === "light" ? import_material_light.default : import_material_dark.default
|
|
91
|
+
prismStyle = theme === "light" ? import_material_light.default : import_material_dark.default,
|
|
92
|
+
service = null,
|
|
93
|
+
historyChangedCallback = null
|
|
92
94
|
}) => {
|
|
93
95
|
const { send, response, idle, stop } = (0, import_llmasaservice_client.useLLM)({
|
|
94
96
|
project_id,
|
|
@@ -123,7 +125,7 @@ var ChatPanel = ({
|
|
|
123
125
|
setIsLoading(true);
|
|
124
126
|
if (lastController) stop(lastController);
|
|
125
127
|
const controller = new AbortController();
|
|
126
|
-
send(initialPrompt, messages, true, true,
|
|
128
|
+
send(initialPrompt, messages, true, true, service, controller);
|
|
127
129
|
setLastPrompt(initialPrompt);
|
|
128
130
|
setLastController(controller);
|
|
129
131
|
setHistory({});
|
|
@@ -148,6 +150,11 @@ var ChatPanel = ({
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}, [response, history]);
|
|
153
|
+
(0, import_react.useEffect)(() => {
|
|
154
|
+
if (historyChangedCallback) {
|
|
155
|
+
historyChangedCallback(history);
|
|
156
|
+
}
|
|
157
|
+
}, [history, historyChangedCallback]);
|
|
151
158
|
const continueChat = () => {
|
|
152
159
|
if (!idle) {
|
|
153
160
|
stop(lastController);
|
|
@@ -171,12 +178,15 @@ var ChatPanel = ({
|
|
|
171
178
|
});
|
|
172
179
|
});
|
|
173
180
|
const controller = new AbortController();
|
|
174
|
-
send(nextPrompt, messagesAndHistory, true, true,
|
|
181
|
+
send(nextPrompt, messagesAndHistory, true, true, service, controller);
|
|
175
182
|
setLastPrompt(nextPrompt);
|
|
176
183
|
setLastController(controller);
|
|
177
184
|
setNextPrompt("");
|
|
178
185
|
}
|
|
179
186
|
};
|
|
187
|
+
const replaceHistory = (newHistory) => {
|
|
188
|
+
setHistory(newHistory);
|
|
189
|
+
};
|
|
180
190
|
function copyToClipboard(text) {
|
|
181
191
|
navigator.clipboard.writeText(text);
|
|
182
192
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -55,7 +55,9 @@ var ChatPanel = ({
|
|
|
55
55
|
url = null,
|
|
56
56
|
scrollToEnd = false,
|
|
57
57
|
initialMessage = "",
|
|
58
|
-
prismStyle = theme === "light" ? materialLight : materialDark
|
|
58
|
+
prismStyle = theme === "light" ? materialLight : materialDark,
|
|
59
|
+
service = null,
|
|
60
|
+
historyChangedCallback = null
|
|
59
61
|
}) => {
|
|
60
62
|
const { send, response, idle, stop } = useLLM({
|
|
61
63
|
project_id,
|
|
@@ -90,7 +92,7 @@ var ChatPanel = ({
|
|
|
90
92
|
setIsLoading(true);
|
|
91
93
|
if (lastController) stop(lastController);
|
|
92
94
|
const controller = new AbortController();
|
|
93
|
-
send(initialPrompt, messages, true, true,
|
|
95
|
+
send(initialPrompt, messages, true, true, service, controller);
|
|
94
96
|
setLastPrompt(initialPrompt);
|
|
95
97
|
setLastController(controller);
|
|
96
98
|
setHistory({});
|
|
@@ -115,6 +117,11 @@ var ChatPanel = ({
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}, [response, history]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (historyChangedCallback) {
|
|
122
|
+
historyChangedCallback(history);
|
|
123
|
+
}
|
|
124
|
+
}, [history, historyChangedCallback]);
|
|
118
125
|
const continueChat = () => {
|
|
119
126
|
if (!idle) {
|
|
120
127
|
stop(lastController);
|
|
@@ -138,12 +145,15 @@ var ChatPanel = ({
|
|
|
138
145
|
});
|
|
139
146
|
});
|
|
140
147
|
const controller = new AbortController();
|
|
141
|
-
send(nextPrompt, messagesAndHistory, true, true,
|
|
148
|
+
send(nextPrompt, messagesAndHistory, true, true, service, controller);
|
|
142
149
|
setLastPrompt(nextPrompt);
|
|
143
150
|
setLastController(controller);
|
|
144
151
|
setNextPrompt("");
|
|
145
152
|
}
|
|
146
153
|
};
|
|
154
|
+
const replaceHistory = (newHistory) => {
|
|
155
|
+
setHistory(newHistory);
|
|
156
|
+
};
|
|
147
157
|
function copyToClipboard(text) {
|
|
148
158
|
navigator.clipboard.writeText(text);
|
|
149
159
|
}
|
package/package.json
CHANGED
package/src/ChatPanel.tsx
CHANGED
|
@@ -26,6 +26,8 @@ export interface ChatPanelProps {
|
|
|
26
26
|
url?: string | null;
|
|
27
27
|
scrollToEnd?: boolean;
|
|
28
28
|
prismStyle?: PrismStyle;
|
|
29
|
+
service?: string | null;
|
|
30
|
+
historyChangedCallback?: (history: { [prompt: string]: string }) => void;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -50,6 +52,8 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
50
52
|
scrollToEnd = false,
|
|
51
53
|
initialMessage = "",
|
|
52
54
|
prismStyle = theme === "light" ? materialLight: materialDark,
|
|
55
|
+
service = null,
|
|
56
|
+
historyChangedCallback = null,
|
|
53
57
|
}) => {
|
|
54
58
|
const { send, response, idle, stop } = useLLM({
|
|
55
59
|
project_id: project_id,
|
|
@@ -95,7 +99,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
95
99
|
if (lastController) stop(lastController);
|
|
96
100
|
const controller = new AbortController();
|
|
97
101
|
|
|
98
|
-
send(initialPrompt, messages, true, true,
|
|
102
|
+
send(initialPrompt, messages, true, true, service, controller);
|
|
99
103
|
setLastPrompt(initialPrompt);
|
|
100
104
|
setLastController(controller);
|
|
101
105
|
setHistory({});
|
|
@@ -123,6 +127,12 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
123
127
|
}
|
|
124
128
|
}, [response, history]);
|
|
125
129
|
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (historyChangedCallback) {
|
|
132
|
+
historyChangedCallback(history);
|
|
133
|
+
}
|
|
134
|
+
}, [history, historyChangedCallback]);
|
|
135
|
+
|
|
126
136
|
const continueChat = () => {
|
|
127
137
|
if (!idle) {
|
|
128
138
|
stop(lastController);
|
|
@@ -156,7 +166,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
156
166
|
});
|
|
157
167
|
|
|
158
168
|
const controller = new AbortController();
|
|
159
|
-
send(nextPrompt, messagesAndHistory, true, true,
|
|
169
|
+
send(nextPrompt, messagesAndHistory, true, true, service, controller);
|
|
160
170
|
|
|
161
171
|
setLastPrompt(nextPrompt);
|
|
162
172
|
setLastController(controller);
|
|
@@ -164,6 +174,10 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
164
174
|
}
|
|
165
175
|
};
|
|
166
176
|
|
|
177
|
+
const replaceHistory = (newHistory: { [prompt: string]: string }) => {
|
|
178
|
+
setHistory(newHistory);
|
|
179
|
+
}
|
|
180
|
+
|
|
167
181
|
function copyToClipboard(text: string) {
|
|
168
182
|
navigator.clipboard.writeText(text);
|
|
169
183
|
}
|