laif-ds 0.2.0 → 0.2.2
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/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/components/ui/chat-message.js +193 -196
- package/dist/components/ui/chat.js +146 -140
- package/dist/components/ui/message-list.js +20 -20
- package/dist/index.d.ts +3 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -1,259 +1,265 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { useAutoScroll as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { CopyButton as
|
|
8
|
-
import { MessageInput as
|
|
9
|
-
import { MessageList as
|
|
10
|
-
import { PromptSuggestions as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import { jsxs as v, Fragment as y, jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as A, useRef as M, useCallback as k, useState as O } from "react";
|
|
4
|
+
import { cn as q } from "../../lib/utils.js";
|
|
5
|
+
import { useAutoScroll as H } from "../../hooks/use-auto-scroll.js";
|
|
6
|
+
import { Button as N } from "./button.js";
|
|
7
|
+
import { CopyButton as S } from "./copy-button.js";
|
|
8
|
+
import { MessageInput as J } from "./message-input.js";
|
|
9
|
+
import { MessageList as K } from "./message-list.js";
|
|
10
|
+
import { PromptSuggestions as Q } from "./prompt-suggestions.js";
|
|
11
|
+
import { Typo as z } from "./typo.js";
|
|
12
|
+
import j from "../../node_modules/lucide-react/dist/esm/icons/save.js";
|
|
13
|
+
import V from "../../node_modules/lucide-react/dist/esm/icons/thumbs-up.js";
|
|
14
|
+
import W from "../../node_modules/lucide-react/dist/esm/icons/thumbs-down.js";
|
|
15
|
+
import X from "../../node_modules/lucide-react/dist/esm/icons/arrow-down.js";
|
|
16
|
+
function Y({
|
|
17
|
+
messages: e,
|
|
18
|
+
welcomeTitle: n = "Da dove iniziamo?",
|
|
19
|
+
handleSubmit: i,
|
|
20
|
+
input: m,
|
|
21
|
+
handleInputChange: c,
|
|
22
|
+
stop: s,
|
|
23
|
+
isGenerating: u,
|
|
22
24
|
append: f,
|
|
23
|
-
suggestions:
|
|
24
|
-
className:
|
|
25
|
-
onRateResponse:
|
|
26
|
-
setMessages:
|
|
27
|
-
transcribeAudio:
|
|
28
|
-
allowAttachments:
|
|
29
|
-
onEdit:
|
|
25
|
+
suggestions: h,
|
|
26
|
+
className: D,
|
|
27
|
+
onRateResponse: w,
|
|
28
|
+
setMessages: x,
|
|
29
|
+
transcribeAudio: L,
|
|
30
|
+
allowAttachments: g = !1,
|
|
31
|
+
onEdit: B,
|
|
30
32
|
onMessageSave: d
|
|
31
33
|
}) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
(
|
|
34
|
+
const P = e.at(-1), T = e.length === 0, I = P?.role === "user", C = M(e);
|
|
35
|
+
C.current = e;
|
|
36
|
+
const U = k(() => {
|
|
37
|
+
if (s?.(), !x) return;
|
|
38
|
+
const o = [...C.current], l = o.findLast(
|
|
39
|
+
(a) => a.role === "assistant"
|
|
38
40
|
);
|
|
39
41
|
if (!l) return;
|
|
40
|
-
let
|
|
42
|
+
let p = !1, b = { ...l };
|
|
41
43
|
if (l.toolInvocations) {
|
|
42
|
-
const
|
|
43
|
-
(
|
|
44
|
-
...
|
|
44
|
+
const a = l.toolInvocations.map(
|
|
45
|
+
(r) => r.state === "call" ? (p = !0, {
|
|
46
|
+
...r,
|
|
45
47
|
state: "result",
|
|
46
48
|
result: {
|
|
47
49
|
content: "Tool execution was cancelled",
|
|
48
50
|
__cancelled: !0
|
|
49
51
|
// Special marker to indicate cancellation
|
|
50
52
|
}
|
|
51
|
-
}) :
|
|
53
|
+
}) : r
|
|
52
54
|
);
|
|
53
|
-
|
|
54
|
-
...
|
|
55
|
-
toolInvocations:
|
|
55
|
+
p && (b = {
|
|
56
|
+
...b,
|
|
57
|
+
toolInvocations: a
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
if (l.parts && l.parts.length > 0) {
|
|
59
|
-
const
|
|
60
|
-
...
|
|
61
|
+
const a = l.parts.map((r) => r.type === "tool-invocation" && r.toolInvocation && r.toolInvocation.state === "call" ? (p = !0, {
|
|
62
|
+
...r,
|
|
61
63
|
toolInvocation: {
|
|
62
|
-
...
|
|
64
|
+
...r.toolInvocation,
|
|
63
65
|
state: "result",
|
|
64
66
|
result: {
|
|
65
67
|
content: "Tool execution was cancelled",
|
|
66
68
|
__cancelled: !0
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
}) :
|
|
70
|
-
|
|
71
|
-
...
|
|
72
|
-
parts:
|
|
71
|
+
}) : r);
|
|
72
|
+
p && (b = {
|
|
73
|
+
...b,
|
|
74
|
+
parts: a
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
(
|
|
77
|
+
if (p) {
|
|
78
|
+
const a = o.findIndex(
|
|
79
|
+
(r) => r.id === l.id
|
|
78
80
|
);
|
|
79
|
-
|
|
81
|
+
a !== -1 && (o[a] = b, x(o));
|
|
80
82
|
}
|
|
81
|
-
}, [
|
|
82
|
-
(
|
|
83
|
-
actions:
|
|
83
|
+
}, [s, x, C]), E = k(
|
|
84
|
+
(o) => ({
|
|
85
|
+
actions: w ? /* @__PURE__ */ v(y, { children: [
|
|
84
86
|
/* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
|
|
85
|
-
|
|
87
|
+
S,
|
|
86
88
|
{
|
|
87
|
-
content:
|
|
89
|
+
content: o.content,
|
|
88
90
|
copyMessage: "Copied response to clipboard!"
|
|
89
91
|
}
|
|
90
92
|
) }),
|
|
91
93
|
d && /* @__PURE__ */ t("div", { className: "border-d-border border-r pr-1", children: /* @__PURE__ */ t(
|
|
92
|
-
|
|
94
|
+
N,
|
|
93
95
|
{
|
|
94
96
|
size: "icon",
|
|
95
97
|
variant: "ghost",
|
|
96
98
|
className: "h-6 w-6",
|
|
97
|
-
onClick: () => d(
|
|
99
|
+
onClick: () => d(o.id, o.content),
|
|
98
100
|
title: "Save message",
|
|
99
|
-
children: /* @__PURE__ */ t(
|
|
101
|
+
children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
|
|
100
102
|
}
|
|
101
103
|
) }),
|
|
102
104
|
/* @__PURE__ */ t(
|
|
103
|
-
|
|
105
|
+
N,
|
|
104
106
|
{
|
|
105
107
|
size: "icon",
|
|
106
108
|
variant: "ghost",
|
|
107
109
|
className: "h-6 w-6",
|
|
108
|
-
onClick: () =>
|
|
109
|
-
children: /* @__PURE__ */ t(
|
|
110
|
+
onClick: () => w(o.id, "thumbs-up"),
|
|
111
|
+
children: /* @__PURE__ */ t(V, { className: "h-4 w-4" })
|
|
110
112
|
}
|
|
111
113
|
),
|
|
112
114
|
/* @__PURE__ */ t(
|
|
113
|
-
|
|
115
|
+
N,
|
|
114
116
|
{
|
|
115
117
|
size: "icon",
|
|
116
118
|
variant: "ghost",
|
|
117
119
|
className: "h-6 w-6",
|
|
118
|
-
onClick: () =>
|
|
119
|
-
children: /* @__PURE__ */ t(
|
|
120
|
+
onClick: () => w(o.id, "thumbs-down"),
|
|
121
|
+
children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
|
|
120
122
|
}
|
|
121
123
|
)
|
|
122
|
-
] }) : /* @__PURE__ */
|
|
124
|
+
] }) : /* @__PURE__ */ v(y, { children: [
|
|
123
125
|
/* @__PURE__ */ t(
|
|
124
|
-
|
|
126
|
+
S,
|
|
125
127
|
{
|
|
126
|
-
content:
|
|
128
|
+
content: o.content,
|
|
127
129
|
copyMessage: "Copied response to clipboard!"
|
|
128
130
|
}
|
|
129
131
|
),
|
|
130
132
|
d && /* @__PURE__ */ t("div", { className: "border-d-border border-l pl-1", children: /* @__PURE__ */ t(
|
|
131
|
-
|
|
133
|
+
N,
|
|
132
134
|
{
|
|
133
135
|
size: "icon",
|
|
134
136
|
variant: "ghost",
|
|
135
137
|
className: "h-6 w-6",
|
|
136
|
-
onClick: () => d(
|
|
138
|
+
onClick: () => d(o.id, o.content),
|
|
137
139
|
title: "Save message",
|
|
138
|
-
children: /* @__PURE__ */ t(
|
|
140
|
+
children: /* @__PURE__ */ t(j, { className: "h-4 w-4" })
|
|
139
141
|
}
|
|
140
142
|
) })
|
|
141
143
|
] }),
|
|
142
144
|
onMessageSave: d
|
|
143
145
|
}),
|
|
144
|
-
[
|
|
146
|
+
[w, d]
|
|
145
147
|
);
|
|
146
|
-
return /* @__PURE__ */
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
return /* @__PURE__ */ v(F, { className: D, children: [
|
|
149
|
+
T && /* @__PURE__ */ t("div", { className: "flex flex-1 flex-col items-center justify-center p-8", children: f && h && /* @__PURE__ */ v(y, { children: [
|
|
150
|
+
/* @__PURE__ */ t(z, { variant: "h3", className: "mb-8 text-center", children: n }),
|
|
151
|
+
/* @__PURE__ */ t(
|
|
152
|
+
Q,
|
|
153
|
+
{
|
|
154
|
+
label: "",
|
|
155
|
+
append: f,
|
|
156
|
+
suggestions: h
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] }) }),
|
|
160
|
+
e.length > 0 ? /* @__PURE__ */ t(Z, { messages: e, children: /* @__PURE__ */ t(
|
|
161
|
+
K,
|
|
157
162
|
{
|
|
158
|
-
messages:
|
|
159
|
-
isTyping:
|
|
160
|
-
messageOptions:
|
|
161
|
-
onEdit:
|
|
163
|
+
messages: e,
|
|
164
|
+
isTyping: I,
|
|
165
|
+
messageOptions: E,
|
|
166
|
+
onEdit: B,
|
|
162
167
|
onMessageSave: d
|
|
163
168
|
}
|
|
164
169
|
) }) : null,
|
|
170
|
+
T && !f && !h && /* @__PURE__ */ t(z, { variant: "h3", className: "mb-8 text-center", children: n }),
|
|
165
171
|
/* @__PURE__ */ t(
|
|
166
|
-
|
|
172
|
+
_,
|
|
167
173
|
{
|
|
168
174
|
className: "flex-shrink-0",
|
|
169
|
-
isPending:
|
|
170
|
-
handleSubmit:
|
|
171
|
-
children: ({ files:
|
|
172
|
-
|
|
175
|
+
isPending: u || I,
|
|
176
|
+
handleSubmit: i,
|
|
177
|
+
children: ({ files: o, setFiles: l }) => /* @__PURE__ */ t(
|
|
178
|
+
J,
|
|
173
179
|
{
|
|
174
|
-
value:
|
|
175
|
-
onChange:
|
|
176
|
-
allowAttachments:
|
|
177
|
-
files:
|
|
180
|
+
value: m,
|
|
181
|
+
onChange: c,
|
|
182
|
+
allowAttachments: g,
|
|
183
|
+
files: o,
|
|
178
184
|
setFiles: l,
|
|
179
|
-
stop:
|
|
180
|
-
isGenerating:
|
|
181
|
-
transcribeAudio:
|
|
185
|
+
stop: U,
|
|
186
|
+
isGenerating: u,
|
|
187
|
+
transcribeAudio: L
|
|
182
188
|
}
|
|
183
189
|
)
|
|
184
190
|
}
|
|
185
191
|
)
|
|
186
192
|
] });
|
|
187
193
|
}
|
|
188
|
-
|
|
189
|
-
function
|
|
190
|
-
messages:
|
|
191
|
-
children:
|
|
194
|
+
Y.displayName = "Chat";
|
|
195
|
+
function Z({
|
|
196
|
+
messages: e,
|
|
197
|
+
children: n
|
|
192
198
|
}) {
|
|
193
199
|
const {
|
|
194
200
|
containerRef: i,
|
|
195
|
-
scrollToBottom:
|
|
196
|
-
handleScroll:
|
|
197
|
-
shouldAutoScroll:
|
|
198
|
-
handleTouchStart:
|
|
199
|
-
} =
|
|
200
|
-
return /* @__PURE__ */
|
|
201
|
+
scrollToBottom: m,
|
|
202
|
+
handleScroll: c,
|
|
203
|
+
shouldAutoScroll: s,
|
|
204
|
+
handleTouchStart: u
|
|
205
|
+
} = H([e]);
|
|
206
|
+
return /* @__PURE__ */ v(
|
|
201
207
|
"div",
|
|
202
208
|
{
|
|
203
209
|
className: "relative flex-1 overflow-y-auto pb-4",
|
|
204
210
|
ref: i,
|
|
205
|
-
onScroll:
|
|
206
|
-
onTouchStart:
|
|
211
|
+
onScroll: c,
|
|
212
|
+
onTouchStart: u,
|
|
207
213
|
children: [
|
|
208
|
-
/* @__PURE__ */ t("div", { className: "max-w-full", children:
|
|
209
|
-
!
|
|
210
|
-
|
|
214
|
+
/* @__PURE__ */ t("div", { className: "max-w-full", children: n }),
|
|
215
|
+
!s && /* @__PURE__ */ t("div", { className: "pointer-events-none absolute right-0 bottom-0 left-0 flex items-end justify-end", children: /* @__PURE__ */ t("div", { className: "sticky bottom-0 left-0 flex w-full justify-end", children: /* @__PURE__ */ t(
|
|
216
|
+
N,
|
|
211
217
|
{
|
|
212
|
-
onClick:
|
|
218
|
+
onClick: m,
|
|
213
219
|
className: "animate-in fade-in-0 slide-in-from-bottom-1 pointer-events-auto h-8 w-8 rounded-full ease-in-out",
|
|
214
220
|
size: "icon",
|
|
215
221
|
variant: "ghost",
|
|
216
|
-
children: /* @__PURE__ */ t(
|
|
222
|
+
children: /* @__PURE__ */ t(X, { className: "h-4 w-4" })
|
|
217
223
|
}
|
|
218
224
|
) }) })
|
|
219
225
|
]
|
|
220
226
|
}
|
|
221
227
|
);
|
|
222
228
|
}
|
|
223
|
-
const
|
|
229
|
+
const F = A(({ className: e, ...n }, i) => /* @__PURE__ */ t(
|
|
224
230
|
"div",
|
|
225
231
|
{
|
|
226
232
|
ref: i,
|
|
227
|
-
className:
|
|
228
|
-
...
|
|
233
|
+
className: q("flex h-full max-h-full w-full flex-col", e),
|
|
234
|
+
...n
|
|
229
235
|
}
|
|
230
236
|
));
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
({ children:
|
|
234
|
-
const [
|
|
235
|
-
return /* @__PURE__ */ t("form", { ref:
|
|
236
|
-
if (!
|
|
237
|
-
|
|
237
|
+
F.displayName = "ChatContainer";
|
|
238
|
+
const _ = A(
|
|
239
|
+
({ children: e, handleSubmit: n, className: i }, m) => {
|
|
240
|
+
const [c, s] = O(null);
|
|
241
|
+
return /* @__PURE__ */ t("form", { ref: m, onSubmit: (f) => {
|
|
242
|
+
if (!c) {
|
|
243
|
+
n(f);
|
|
238
244
|
return;
|
|
239
245
|
}
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
}, className: i, children:
|
|
246
|
+
const h = $(c);
|
|
247
|
+
n(f, { experimental_attachments: h }), s(null);
|
|
248
|
+
}, className: i, children: e({ files: c, setFiles: s }) });
|
|
243
249
|
}
|
|
244
250
|
);
|
|
245
|
-
|
|
246
|
-
function
|
|
251
|
+
_.displayName = "ChatForm";
|
|
252
|
+
function $(e) {
|
|
247
253
|
if (typeof window > "u")
|
|
248
254
|
return {};
|
|
249
|
-
const
|
|
250
|
-
for (const i of Array.from(
|
|
251
|
-
|
|
252
|
-
return
|
|
255
|
+
const n = new DataTransfer();
|
|
256
|
+
for (const i of Array.from(e))
|
|
257
|
+
n.items.add(i);
|
|
258
|
+
return n.files;
|
|
253
259
|
}
|
|
254
260
|
export {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
261
|
+
Y as Chat,
|
|
262
|
+
F as ChatContainer,
|
|
263
|
+
_ as ChatForm,
|
|
264
|
+
Z as ChatMessages
|
|
259
265
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { ChatMessage as
|
|
4
|
-
import { TypingIndicator as
|
|
5
|
-
function
|
|
2
|
+
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { ChatMessage as l } from "./chat-message.js";
|
|
4
|
+
import { TypingIndicator as u } from "./typing-indicator.js";
|
|
5
|
+
function h({
|
|
6
6
|
messages: n,
|
|
7
|
-
showTimeStamps:
|
|
8
|
-
isTyping:
|
|
9
|
-
messageOptions:
|
|
7
|
+
showTimeStamps: c = !0,
|
|
8
|
+
isTyping: d = !1,
|
|
9
|
+
messageOptions: o,
|
|
10
10
|
onEdit: t,
|
|
11
|
-
onMessageSave:
|
|
11
|
+
onMessageSave: e
|
|
12
12
|
}) {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
n.map((
|
|
15
|
-
const
|
|
13
|
+
return /* @__PURE__ */ a("div", { className: "space-y-4 overflow-visible", children: [
|
|
14
|
+
n.map((i) => {
|
|
15
|
+
const f = typeof o == "function" ? o(i) : o;
|
|
16
16
|
return /* @__PURE__ */ r(
|
|
17
|
-
|
|
17
|
+
l,
|
|
18
18
|
{
|
|
19
|
-
showTimeStamp:
|
|
20
|
-
...
|
|
21
|
-
...
|
|
22
|
-
onEdit: t ? (
|
|
23
|
-
onMessageSave:
|
|
19
|
+
showTimeStamp: c,
|
|
20
|
+
...i,
|
|
21
|
+
...f,
|
|
22
|
+
onEdit: t ? (p) => t(i.id, p) : void 0,
|
|
23
|
+
onMessageSave: e
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
i.id
|
|
26
26
|
);
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
d && /* @__PURE__ */ r(u, {})
|
|
29
29
|
] });
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
h as MessageList
|
|
33
33
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -436,7 +436,7 @@ export declare function ChartTooltipContent({ active, payload, className, indica
|
|
|
436
436
|
labelKey?: string;
|
|
437
437
|
} & React_2.HTMLAttributes<HTMLDivElement>): JSX.Element | null;
|
|
438
438
|
|
|
439
|
-
export declare function Chat({ messages, handleSubmit, input, handleInputChange, stop, isGenerating, append, suggestions, className, onRateResponse, setMessages, transcribeAudio, allowAttachments, onEdit, onMessageSave, }: ChatProps): JSX.Element;
|
|
439
|
+
export declare function Chat({ messages, welcomeTitle, handleSubmit, input, handleInputChange, stop, isGenerating, append, suggestions, className, onRateResponse, setMessages, transcribeAudio, allowAttachments, onEdit, onMessageSave, }: ChatProps): JSX.Element;
|
|
440
440
|
|
|
441
441
|
export declare namespace Chat {
|
|
442
442
|
var displayName: string;
|
|
@@ -471,6 +471,7 @@ export declare interface ChatMessageProps extends Message {
|
|
|
471
471
|
showTimeStamp?: boolean;
|
|
472
472
|
animation?: Animation_2;
|
|
473
473
|
actions?: default_3.ReactNode;
|
|
474
|
+
editable?: boolean;
|
|
474
475
|
onEdit?: (newContent: string) => void;
|
|
475
476
|
onMessageSave?: (messageId: string, content: string) => void;
|
|
476
477
|
}
|
|
@@ -499,6 +500,7 @@ declare interface ChatPropsBase {
|
|
|
499
500
|
allowAttachments?: boolean;
|
|
500
501
|
onEdit?: (messageId: string, newContent: string) => void;
|
|
501
502
|
onMessageSave?: (messageId: string, content: string) => void;
|
|
503
|
+
welcomeTitle?: string;
|
|
502
504
|
}
|
|
503
505
|
|
|
504
506
|
declare interface ChatPropsWithoutSuggestions extends ChatPropsBase {
|