@luxonis/component-lib 1.0.9 → 1.0.10
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.js +23 -15
- package/dist/index.mjs +23 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1305,6 +1305,7 @@ function ChatButton(props) {
|
|
|
1305
1305
|
loading: false
|
|
1306
1306
|
}
|
|
1307
1307
|
]);
|
|
1308
|
+
const [slackThreadTs, setSlackThreadTs] = (0, import_react12.useState)(null);
|
|
1308
1309
|
const inputRef = (0, import_react12.useRef)(null);
|
|
1309
1310
|
const messageListRef = (0, import_react12.useRef)(null);
|
|
1310
1311
|
const formRef = (0, import_react12.useRef)(null);
|
|
@@ -1323,18 +1324,21 @@ function ChatButton(props) {
|
|
|
1323
1324
|
const fetchData = (0, import_react12.useCallback)(
|
|
1324
1325
|
async (message) => {
|
|
1325
1326
|
try {
|
|
1326
|
-
const response = await fetch(
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1327
|
+
const response = await fetch(
|
|
1328
|
+
slackThreadTs ? `https://chat.luxonis.com/api/chat?slack_thread_ts=${slackThreadTs}` : "https://chat.luxonis.com/api/chat",
|
|
1329
|
+
{
|
|
1330
|
+
method: "POST",
|
|
1331
|
+
headers: {
|
|
1332
|
+
"Content-Type": "application/json"
|
|
1333
|
+
},
|
|
1334
|
+
body: JSON.stringify({
|
|
1335
|
+
query: [...messages.slice(1, messages.length), { user: "user", message }].map((m) => {
|
|
1336
|
+
return { role: m.user, content: m.message };
|
|
1337
|
+
}),
|
|
1338
|
+
model: "gpt-4.1"
|
|
1339
|
+
})
|
|
1340
|
+
}
|
|
1341
|
+
);
|
|
1338
1342
|
if (!response.ok) {
|
|
1339
1343
|
throw new Error(`Request failed with status ${response.status}`);
|
|
1340
1344
|
}
|
|
@@ -1342,12 +1346,16 @@ function ChatButton(props) {
|
|
|
1342
1346
|
if (!contentType || !contentType.includes("application/json")) {
|
|
1343
1347
|
throw new Error("Response is not in JSON format");
|
|
1344
1348
|
}
|
|
1345
|
-
|
|
1349
|
+
const responseJson = await response.json();
|
|
1350
|
+
if (responseJson.slack_thread_ts && !slackThreadTs) {
|
|
1351
|
+
setSlackThreadTs(responseJson.slack_thread_ts);
|
|
1352
|
+
}
|
|
1353
|
+
return responseJson;
|
|
1346
1354
|
} catch {
|
|
1347
1355
|
return null;
|
|
1348
1356
|
}
|
|
1349
1357
|
},
|
|
1350
|
-
[messages]
|
|
1358
|
+
[messages, slackThreadTs]
|
|
1351
1359
|
);
|
|
1352
1360
|
const onSubmit = (0, import_react12.useCallback)(
|
|
1353
1361
|
async (e) => {
|
|
@@ -1443,7 +1451,7 @@ function ChatButton(props) {
|
|
|
1443
1451
|
animationDuration: "150ms",
|
|
1444
1452
|
animationTimingFunction: "ease-in"
|
|
1445
1453
|
},
|
|
1446
|
-
className: "flex
|
|
1454
|
+
className: "flex size-full items-center justify-center",
|
|
1447
1455
|
children: chatOpened ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react13.Icon, { icon: "mdi:close", className: "size-[32px] text-white" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("img", { src: "https://docs.luxonis.com/static/images/icons/chat-icon.svg", width: "32", height: "32", alt: "Chat" })
|
|
1448
1456
|
},
|
|
1449
1457
|
iconKey
|
package/dist/index.mjs
CHANGED
|
@@ -1211,6 +1211,7 @@ function ChatButton(props) {
|
|
|
1211
1211
|
loading: false
|
|
1212
1212
|
}
|
|
1213
1213
|
]);
|
|
1214
|
+
const [slackThreadTs, setSlackThreadTs] = useState5(null);
|
|
1214
1215
|
const inputRef = useRef4(null);
|
|
1215
1216
|
const messageListRef = useRef4(null);
|
|
1216
1217
|
const formRef = useRef4(null);
|
|
@@ -1229,18 +1230,21 @@ function ChatButton(props) {
|
|
|
1229
1230
|
const fetchData = useCallback(
|
|
1230
1231
|
async (message) => {
|
|
1231
1232
|
try {
|
|
1232
|
-
const response = await fetch(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1233
|
+
const response = await fetch(
|
|
1234
|
+
slackThreadTs ? `https://chat.luxonis.com/api/chat?slack_thread_ts=${slackThreadTs}` : "https://chat.luxonis.com/api/chat",
|
|
1235
|
+
{
|
|
1236
|
+
method: "POST",
|
|
1237
|
+
headers: {
|
|
1238
|
+
"Content-Type": "application/json"
|
|
1239
|
+
},
|
|
1240
|
+
body: JSON.stringify({
|
|
1241
|
+
query: [...messages.slice(1, messages.length), { user: "user", message }].map((m) => {
|
|
1242
|
+
return { role: m.user, content: m.message };
|
|
1243
|
+
}),
|
|
1244
|
+
model: "gpt-4.1"
|
|
1245
|
+
})
|
|
1246
|
+
}
|
|
1247
|
+
);
|
|
1244
1248
|
if (!response.ok) {
|
|
1245
1249
|
throw new Error(`Request failed with status ${response.status}`);
|
|
1246
1250
|
}
|
|
@@ -1248,12 +1252,16 @@ function ChatButton(props) {
|
|
|
1248
1252
|
if (!contentType || !contentType.includes("application/json")) {
|
|
1249
1253
|
throw new Error("Response is not in JSON format");
|
|
1250
1254
|
}
|
|
1251
|
-
|
|
1255
|
+
const responseJson = await response.json();
|
|
1256
|
+
if (responseJson.slack_thread_ts && !slackThreadTs) {
|
|
1257
|
+
setSlackThreadTs(responseJson.slack_thread_ts);
|
|
1258
|
+
}
|
|
1259
|
+
return responseJson;
|
|
1252
1260
|
} catch {
|
|
1253
1261
|
return null;
|
|
1254
1262
|
}
|
|
1255
1263
|
},
|
|
1256
|
-
[messages]
|
|
1264
|
+
[messages, slackThreadTs]
|
|
1257
1265
|
);
|
|
1258
1266
|
const onSubmit = useCallback(
|
|
1259
1267
|
async (e) => {
|
|
@@ -1349,7 +1357,7 @@ function ChatButton(props) {
|
|
|
1349
1357
|
animationDuration: "150ms",
|
|
1350
1358
|
animationTimingFunction: "ease-in"
|
|
1351
1359
|
},
|
|
1352
|
-
className: "flex
|
|
1360
|
+
className: "flex size-full items-center justify-center",
|
|
1353
1361
|
children: chatOpened ? /* @__PURE__ */ jsx24(Icon7, { icon: "mdi:close", className: "size-[32px] text-white" }) : /* @__PURE__ */ jsx24("img", { src: "https://docs.luxonis.com/static/images/icons/chat-icon.svg", width: "32", height: "32", alt: "Chat" })
|
|
1354
1362
|
},
|
|
1355
1363
|
iconKey
|