@luxonis/component-lib 1.0.9 → 1.0.11

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 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);
@@ -1332,7 +1333,9 @@ function ChatButton(props) {
1332
1333
  query: [...messages.slice(1, messages.length), { user: "user", message }].map((m) => {
1333
1334
  return { role: m.user, content: m.message };
1334
1335
  }),
1335
- model: "gpt-4.1"
1336
+ model: "gpt-4.1",
1337
+ rerank: true,
1338
+ slack_thread_ts: slackThreadTs
1336
1339
  })
1337
1340
  });
1338
1341
  if (!response.ok) {
@@ -1342,12 +1345,16 @@ function ChatButton(props) {
1342
1345
  if (!contentType || !contentType.includes("application/json")) {
1343
1346
  throw new Error("Response is not in JSON format");
1344
1347
  }
1345
- return await response.json();
1348
+ const responseJson = await response.json();
1349
+ if (responseJson.slack_thread_ts && !slackThreadTs) {
1350
+ setSlackThreadTs(responseJson.slack_thread_ts);
1351
+ }
1352
+ return responseJson;
1346
1353
  } catch {
1347
1354
  return null;
1348
1355
  }
1349
1356
  },
1350
- [messages]
1357
+ [messages, slackThreadTs]
1351
1358
  );
1352
1359
  const onSubmit = (0, import_react12.useCallback)(
1353
1360
  async (e) => {
@@ -1443,7 +1450,7 @@ function ChatButton(props) {
1443
1450
  animationDuration: "150ms",
1444
1451
  animationTimingFunction: "ease-in"
1445
1452
  },
1446
- className: "flex w-full items-center justify-center",
1453
+ className: "flex size-full items-center justify-center",
1447
1454
  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
1455
  },
1449
1456
  iconKey
@@ -1463,14 +1470,17 @@ function ChatButton(props) {
1463
1470
  "button",
1464
1471
  {
1465
1472
  className: "flex !size-12 !p-2",
1466
- onClick: () => setMessages([
1467
- {
1468
- id: -1,
1469
- user: "bot",
1470
- message: "Welcome! I'm here to assist you by searching Luxonis documentation and past forum discussions for answers. How can I help you today?",
1471
- loading: false
1472
- }
1473
- ]),
1473
+ onClick: () => {
1474
+ setMessages([
1475
+ {
1476
+ id: -1,
1477
+ user: "bot",
1478
+ message: "Welcome! I'm here to assist you by searching Luxonis documentation and past forum discussions for answers. How can I help you today?",
1479
+ loading: false
1480
+ }
1481
+ ]);
1482
+ setSlackThreadTs(null);
1483
+ },
1474
1484
  children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react13.Icon, { icon: "fluent:chat-add-16-regular", className: "text-primary", width: 32, height: 32 })
1475
1485
  }
1476
1486
  ) })
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);
@@ -1238,7 +1239,9 @@ function ChatButton(props) {
1238
1239
  query: [...messages.slice(1, messages.length), { user: "user", message }].map((m) => {
1239
1240
  return { role: m.user, content: m.message };
1240
1241
  }),
1241
- model: "gpt-4.1"
1242
+ model: "gpt-4.1",
1243
+ rerank: true,
1244
+ slack_thread_ts: slackThreadTs
1242
1245
  })
1243
1246
  });
1244
1247
  if (!response.ok) {
@@ -1248,12 +1251,16 @@ function ChatButton(props) {
1248
1251
  if (!contentType || !contentType.includes("application/json")) {
1249
1252
  throw new Error("Response is not in JSON format");
1250
1253
  }
1251
- return await response.json();
1254
+ const responseJson = await response.json();
1255
+ if (responseJson.slack_thread_ts && !slackThreadTs) {
1256
+ setSlackThreadTs(responseJson.slack_thread_ts);
1257
+ }
1258
+ return responseJson;
1252
1259
  } catch {
1253
1260
  return null;
1254
1261
  }
1255
1262
  },
1256
- [messages]
1263
+ [messages, slackThreadTs]
1257
1264
  );
1258
1265
  const onSubmit = useCallback(
1259
1266
  async (e) => {
@@ -1349,7 +1356,7 @@ function ChatButton(props) {
1349
1356
  animationDuration: "150ms",
1350
1357
  animationTimingFunction: "ease-in"
1351
1358
  },
1352
- className: "flex w-full items-center justify-center",
1359
+ className: "flex size-full items-center justify-center",
1353
1360
  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
1361
  },
1355
1362
  iconKey
@@ -1369,14 +1376,17 @@ function ChatButton(props) {
1369
1376
  "button",
1370
1377
  {
1371
1378
  className: "flex !size-12 !p-2",
1372
- onClick: () => setMessages([
1373
- {
1374
- id: -1,
1375
- user: "bot",
1376
- message: "Welcome! I'm here to assist you by searching Luxonis documentation and past forum discussions for answers. How can I help you today?",
1377
- loading: false
1378
- }
1379
- ]),
1379
+ onClick: () => {
1380
+ setMessages([
1381
+ {
1382
+ id: -1,
1383
+ user: "bot",
1384
+ message: "Welcome! I'm here to assist you by searching Luxonis documentation and past forum discussions for answers. How can I help you today?",
1385
+ loading: false
1386
+ }
1387
+ ]);
1388
+ setSlackThreadTs(null);
1389
+ },
1380
1390
  children: /* @__PURE__ */ jsx24(Icon7, { icon: "fluent:chat-add-16-regular", className: "text-primary", width: 32, height: 32 })
1381
1391
  }
1382
1392
  ) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxonis/component-lib",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Luxonis website-component-lib",
5
5
  "publishConfig": {
6
6
  "access": "public"