@akropolys/kiku 1.5.5 → 1.5.8
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 +97 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1488,19 +1488,95 @@ var getFriendlyError = (err) => {
|
|
|
1488
1488
|
return str;
|
|
1489
1489
|
}
|
|
1490
1490
|
};
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1491
|
+
function parseThinking(text) {
|
|
1492
|
+
const openMatch = text.match(/<\s*thinking\s*>/i);
|
|
1493
|
+
if (!openMatch) {
|
|
1494
|
+
return { thinking: "", content: text, isComplete: true };
|
|
1495
|
+
}
|
|
1496
|
+
const openIdx = openMatch.index ?? 0;
|
|
1497
|
+
const openTagLength = openMatch[0].length;
|
|
1498
|
+
const start = openIdx + openTagLength;
|
|
1499
|
+
const contentBefore = text.slice(0, openIdx);
|
|
1500
|
+
const textAfterOpen = text.slice(start);
|
|
1501
|
+
const closeMatch = textAfterOpen.match(/<\/\s*thinking\s*>/i);
|
|
1502
|
+
if (!closeMatch) {
|
|
1503
|
+
return {
|
|
1504
|
+
thinking: textAfterOpen,
|
|
1505
|
+
content: contentBefore,
|
|
1506
|
+
isComplete: false
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
const closeIdx = closeMatch.index ?? 0;
|
|
1510
|
+
const closeTagLength = closeMatch[0].length;
|
|
1511
|
+
return {
|
|
1512
|
+
thinking: textAfterOpen.slice(0, closeIdx),
|
|
1513
|
+
content: contentBefore + textAfterOpen.slice(closeIdx + closeTagLength),
|
|
1514
|
+
isComplete: true
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
function ThinkingBlock({ text, isComplete }) {
|
|
1518
|
+
const [isOpen, setIsOpen] = (0, import_react5.useState)(true);
|
|
1519
|
+
(0, import_react5.useEffect)(() => {
|
|
1520
|
+
if (!isComplete) {
|
|
1521
|
+
setIsOpen(true);
|
|
1522
|
+
}
|
|
1523
|
+
}, [isComplete]);
|
|
1524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
|
|
1525
|
+
marginBottom: "12px",
|
|
1526
|
+
borderLeft: "2px solid #e4e4e7",
|
|
1527
|
+
paddingLeft: "10px",
|
|
1528
|
+
fontSize: "0.825rem",
|
|
1529
|
+
backgroundColor: "rgba(244, 244, 245, 0.4)",
|
|
1530
|
+
padding: "8px 10px",
|
|
1531
|
+
borderRadius: "0 6px 6px 0"
|
|
1532
|
+
}, children: [
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1534
|
+
"div",
|
|
1535
|
+
{
|
|
1536
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1537
|
+
style: {
|
|
1538
|
+
display: "flex",
|
|
1539
|
+
alignItems: "center",
|
|
1540
|
+
gap: "6px",
|
|
1541
|
+
color: "#71717a",
|
|
1542
|
+
cursor: "pointer",
|
|
1543
|
+
fontWeight: 500,
|
|
1544
|
+
userSelect: "none"
|
|
1545
|
+
},
|
|
1546
|
+
children: [
|
|
1547
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1548
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { animation: !isComplete ? "spin 3s linear infinite" : "none" }, children: [
|
|
1549
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1550
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 6v6l4 2" })
|
|
1551
|
+
] }),
|
|
1552
|
+
"Thinking Process"
|
|
1553
|
+
] }),
|
|
1554
|
+
!isComplete && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
|
|
1555
|
+
width: "6px",
|
|
1556
|
+
height: "6px",
|
|
1557
|
+
borderRadius: "50%",
|
|
1558
|
+
backgroundColor: "#3b82f6",
|
|
1559
|
+
display: "inline-block",
|
|
1560
|
+
animation: "hsk-pulse 1.2s infinite ease-in-out"
|
|
1561
|
+
} }),
|
|
1562
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
|
|
1563
|
+
fontSize: "0.7rem",
|
|
1564
|
+
marginLeft: "auto",
|
|
1565
|
+
transform: isOpen ? "rotate(90deg)" : "none",
|
|
1566
|
+
transition: "transform 0.1s"
|
|
1567
|
+
}, children: "\u25B6" })
|
|
1568
|
+
]
|
|
1569
|
+
}
|
|
1570
|
+
),
|
|
1571
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1572
|
+
marginTop: "6px",
|
|
1573
|
+
color: "#52525b",
|
|
1574
|
+
whiteSpace: "pre-wrap",
|
|
1575
|
+
lineHeight: "1.4",
|
|
1576
|
+
fontStyle: "italic"
|
|
1577
|
+
}, children: text })
|
|
1578
|
+
] });
|
|
1579
|
+
}
|
|
1504
1580
|
var PROPERTY_CHIPS = [
|
|
1505
1581
|
"3 bedroom apartments",
|
|
1506
1582
|
"Houses under KSh 5,000,000",
|
|
@@ -1525,7 +1601,6 @@ function ChatModal({
|
|
|
1525
1601
|
const client = (0, import_sdk6.useAkropolysContext)();
|
|
1526
1602
|
const { messages, sources, loading, streaming, error, lastAction, lastIntent, send, reset, referencedIds } = (0, import_sdk4.useKiku)();
|
|
1527
1603
|
const [input, setInput] = (0, import_react5.useState)("");
|
|
1528
|
-
const [loadingMessageIndex, setLoadingMessageIndex] = (0, import_react5.useState)(0);
|
|
1529
1604
|
const [attachments, setAttachments] = (0, import_react5.useState)([]);
|
|
1530
1605
|
const imageInputRef = (0, import_react5.useRef)(null);
|
|
1531
1606
|
const handleImageFiles = (files) => {
|
|
@@ -1581,16 +1656,6 @@ function ChatModal({
|
|
|
1581
1656
|
const activeChips = chips === DEFAULT_CHIPS && isProperty ? PROPERTY_CHIPS : chips;
|
|
1582
1657
|
const activeTitle = title === "Shopping Assistant" && isProperty ? "Property Assistant" : title;
|
|
1583
1658
|
const activePlaceholder = placeholder === "Ask me anything \u2014 gifts, budget, use case\u2026" && isProperty ? "Ask me anything \u2014 location, budget, bedrooms\u2026" : placeholder;
|
|
1584
|
-
(0, import_react5.useEffect)(() => {
|
|
1585
|
-
if (loading && !streaming) {
|
|
1586
|
-
const interval = setInterval(() => {
|
|
1587
|
-
setLoadingMessageIndex((prev) => (prev + 1) % LOADING_MESSAGES.length);
|
|
1588
|
-
}, 1500);
|
|
1589
|
-
return () => clearInterval(interval);
|
|
1590
|
-
} else {
|
|
1591
|
-
setLoadingMessageIndex(0);
|
|
1592
|
-
}
|
|
1593
|
-
}, [loading, streaming]);
|
|
1594
1659
|
const [selectedProduct, setSelectedProduct] = (0, import_react5.useState)(null);
|
|
1595
1660
|
const bottomRef = (0, import_react5.useRef)(null);
|
|
1596
1661
|
const textareaRef = (0, import_react5.useRef)(null);
|
|
@@ -1861,7 +1926,13 @@ function ChatModal({
|
|
|
1861
1926
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
|
|
1862
1927
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SparkleIcon2, {}) }),
|
|
1863
1928
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-body", children: [
|
|
1864
|
-
|
|
1929
|
+
(() => {
|
|
1930
|
+
const { thinking, content, isComplete } = parseThinking(displayContent);
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1932
|
+
thinking && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingBlock, { text: thinking, isComplete }),
|
|
1933
|
+
content && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: renderMarkdown(content) })
|
|
1934
|
+
] });
|
|
1935
|
+
})(),
|
|
1865
1936
|
isLast && lastIntent === "compare" && sources.length >= 2 && !replayMessages && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ComparisonMatrix, { sources, defaultCurrency }),
|
|
1866
1937
|
isLast && sources.length > 0 && lastIntent !== "compare" && lastAction?.type !== "request_phone" && lastAction?.type !== "awaiting_payment" && lastAction?.type !== "checkout" && !msg.cartSnapshot && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1867
1938
|
SourcesCarousel,
|
|
@@ -1927,7 +1998,7 @@ function ChatModal({
|
|
|
1927
1998
|
50% { opacity: 1; }
|
|
1928
1999
|
}
|
|
1929
2000
|
` }),
|
|
1930
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { fontSize: "0.85rem", color: "#6b7280", fontStyle: "italic", animation: "hsk-pulse 1.5s infinite ease-in-out" }, children:
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { fontSize: "0.85rem", color: "#6b7280", fontStyle: "italic", animation: "hsk-pulse 1.5s infinite ease-in-out" }, children: isProperty ? "Analyzing listings..." : "Searching catalog..." }),
|
|
1931
2002
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-typing", style: { margin: 0, alignSelf: "flex-start" }, children: [
|
|
1932
2003
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-dot" }),
|
|
1933
2004
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-dot" }),
|