@akropolys/kiku 1.5.4 → 1.5.7
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 +90 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1453,19 +1453,87 @@ var getFriendlyError = (err) => {
|
|
|
1453
1453
|
return str;
|
|
1454
1454
|
}
|
|
1455
1455
|
};
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1456
|
+
function parseThinking(text) {
|
|
1457
|
+
const openTag = "<thinking>";
|
|
1458
|
+
const closeTag = "</thinking>";
|
|
1459
|
+
const openIdx = text.indexOf(openTag);
|
|
1460
|
+
if (openIdx === -1) {
|
|
1461
|
+
return { thinking: "", content: text, isComplete: true };
|
|
1462
|
+
}
|
|
1463
|
+
const start = openIdx + openTag.length;
|
|
1464
|
+
const closeIdx = text.indexOf(closeTag, start);
|
|
1465
|
+
if (closeIdx === -1) {
|
|
1466
|
+
return { thinking: text.slice(start), content: "", isComplete: false };
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
thinking: text.slice(start, closeIdx),
|
|
1470
|
+
content: text.slice(closeIdx + closeTag.length),
|
|
1471
|
+
isComplete: true
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
function ThinkingBlock({ text, isComplete }) {
|
|
1475
|
+
const [isOpen, setIsOpen] = useState5(true);
|
|
1476
|
+
useEffect3(() => {
|
|
1477
|
+
if (!isComplete) {
|
|
1478
|
+
setIsOpen(true);
|
|
1479
|
+
}
|
|
1480
|
+
}, [isComplete]);
|
|
1481
|
+
return /* @__PURE__ */ jsxs6("div", { style: {
|
|
1482
|
+
marginBottom: "12px",
|
|
1483
|
+
borderLeft: "2px solid #e4e4e7",
|
|
1484
|
+
paddingLeft: "10px",
|
|
1485
|
+
fontSize: "0.825rem",
|
|
1486
|
+
backgroundColor: "rgba(244, 244, 245, 0.4)",
|
|
1487
|
+
padding: "8px 10px",
|
|
1488
|
+
borderRadius: "0 6px 6px 0"
|
|
1489
|
+
}, children: [
|
|
1490
|
+
/* @__PURE__ */ jsxs6(
|
|
1491
|
+
"div",
|
|
1492
|
+
{
|
|
1493
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1494
|
+
style: {
|
|
1495
|
+
display: "flex",
|
|
1496
|
+
alignItems: "center",
|
|
1497
|
+
gap: "6px",
|
|
1498
|
+
color: "#71717a",
|
|
1499
|
+
cursor: "pointer",
|
|
1500
|
+
fontWeight: 500,
|
|
1501
|
+
userSelect: "none"
|
|
1502
|
+
},
|
|
1503
|
+
children: [
|
|
1504
|
+
/* @__PURE__ */ jsxs6("span", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1505
|
+
/* @__PURE__ */ jsxs6("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: [
|
|
1506
|
+
/* @__PURE__ */ jsx7("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1507
|
+
/* @__PURE__ */ jsx7("path", { d: "M12 6v6l4 2" })
|
|
1508
|
+
] }),
|
|
1509
|
+
"Thinking Process"
|
|
1510
|
+
] }),
|
|
1511
|
+
!isComplete && /* @__PURE__ */ jsx7("span", { style: {
|
|
1512
|
+
width: "6px",
|
|
1513
|
+
height: "6px",
|
|
1514
|
+
borderRadius: "50%",
|
|
1515
|
+
backgroundColor: "#3b82f6",
|
|
1516
|
+
display: "inline-block",
|
|
1517
|
+
animation: "hsk-pulse 1.2s infinite ease-in-out"
|
|
1518
|
+
} }),
|
|
1519
|
+
/* @__PURE__ */ jsx7("span", { style: {
|
|
1520
|
+
fontSize: "0.7rem",
|
|
1521
|
+
marginLeft: "auto",
|
|
1522
|
+
transform: isOpen ? "rotate(90deg)" : "none",
|
|
1523
|
+
transition: "transform 0.1s"
|
|
1524
|
+
}, children: "\u25B6" })
|
|
1525
|
+
]
|
|
1526
|
+
}
|
|
1527
|
+
),
|
|
1528
|
+
isOpen && /* @__PURE__ */ jsx7("div", { style: {
|
|
1529
|
+
marginTop: "6px",
|
|
1530
|
+
color: "#52525b",
|
|
1531
|
+
whiteSpace: "pre-wrap",
|
|
1532
|
+
lineHeight: "1.4",
|
|
1533
|
+
fontStyle: "italic"
|
|
1534
|
+
}, children: text })
|
|
1535
|
+
] });
|
|
1536
|
+
}
|
|
1469
1537
|
var PROPERTY_CHIPS = [
|
|
1470
1538
|
"3 bedroom apartments",
|
|
1471
1539
|
"Houses under KSh 5,000,000",
|
|
@@ -1490,7 +1558,6 @@ function ChatModal({
|
|
|
1490
1558
|
const client = useAkropolysContext3();
|
|
1491
1559
|
const { messages, sources, loading, streaming, error, lastAction, lastIntent, send, reset, referencedIds } = useKiku2();
|
|
1492
1560
|
const [input, setInput] = useState5("");
|
|
1493
|
-
const [loadingMessageIndex, setLoadingMessageIndex] = useState5(0);
|
|
1494
1561
|
const [attachments, setAttachments] = useState5([]);
|
|
1495
1562
|
const imageInputRef = useRef5(null);
|
|
1496
1563
|
const handleImageFiles = (files) => {
|
|
@@ -1546,16 +1613,6 @@ function ChatModal({
|
|
|
1546
1613
|
const activeChips = chips === DEFAULT_CHIPS && isProperty ? PROPERTY_CHIPS : chips;
|
|
1547
1614
|
const activeTitle = title === "Shopping Assistant" && isProperty ? "Property Assistant" : title;
|
|
1548
1615
|
const activePlaceholder = placeholder === "Ask me anything \u2014 gifts, budget, use case\u2026" && isProperty ? "Ask me anything \u2014 location, budget, bedrooms\u2026" : placeholder;
|
|
1549
|
-
useEffect3(() => {
|
|
1550
|
-
if (loading && !streaming) {
|
|
1551
|
-
const interval = setInterval(() => {
|
|
1552
|
-
setLoadingMessageIndex((prev) => (prev + 1) % LOADING_MESSAGES.length);
|
|
1553
|
-
}, 1500);
|
|
1554
|
-
return () => clearInterval(interval);
|
|
1555
|
-
} else {
|
|
1556
|
-
setLoadingMessageIndex(0);
|
|
1557
|
-
}
|
|
1558
|
-
}, [loading, streaming]);
|
|
1559
1616
|
const [selectedProduct, setSelectedProduct] = useState5(null);
|
|
1560
1617
|
const bottomRef = useRef5(null);
|
|
1561
1618
|
const textareaRef = useRef5(null);
|
|
@@ -1826,7 +1883,13 @@ function ChatModal({
|
|
|
1826
1883
|
] }) : /* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-msg", children: [
|
|
1827
1884
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-icon", style: { display: "flex", alignItems: "center" }, children: /* @__PURE__ */ jsx7(SparkleIcon2, {}) }),
|
|
1828
1885
|
/* @__PURE__ */ jsxs6("div", { className: "hsk-cb-ai-body", children: [
|
|
1829
|
-
|
|
1886
|
+
(() => {
|
|
1887
|
+
const { thinking, content, isComplete } = parseThinking(displayContent);
|
|
1888
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
1889
|
+
thinking && /* @__PURE__ */ jsx7(ThinkingBlock, { text: thinking, isComplete }),
|
|
1890
|
+
content && /* @__PURE__ */ jsx7("div", { className: "hsk-cb-ai-text", children: renderMarkdown(content) })
|
|
1891
|
+
] });
|
|
1892
|
+
})(),
|
|
1830
1893
|
isLast && lastIntent === "compare" && sources.length >= 2 && !replayMessages && /* @__PURE__ */ jsx7(ComparisonMatrix, { sources, defaultCurrency }),
|
|
1831
1894
|
isLast && sources.length > 0 && lastIntent !== "compare" && lastAction?.type !== "request_phone" && lastAction?.type !== "awaiting_payment" && lastAction?.type !== "checkout" && !msg.cartSnapshot && /* @__PURE__ */ jsx7(
|
|
1832
1895
|
SourcesCarousel,
|
|
@@ -1892,7 +1955,7 @@ function ChatModal({
|
|
|
1892
1955
|
50% { opacity: 1; }
|
|
1893
1956
|
}
|
|
1894
1957
|
` }),
|
|
1895
|
-
/* @__PURE__ */ jsx7("div", { style: { fontSize: "0.85rem", color: "#6b7280", fontStyle: "italic", animation: "hsk-pulse 1.5s infinite ease-in-out" }, children:
|
|
1958
|
+
/* @__PURE__ */ jsx7("div", { style: { fontSize: "0.85rem", color: "#6b7280", fontStyle: "italic", animation: "hsk-pulse 1.5s infinite ease-in-out" }, children: isProperty ? "Analyzing listings..." : "Searching catalog..." }),
|
|
1896
1959
|
/* @__PURE__ */ jsxs6("div", { className: "hsk-cb-typing", style: { margin: 0, alignSelf: "flex-start" }, children: [
|
|
1897
1960
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-dot" }),
|
|
1898
1961
|
/* @__PURE__ */ jsx7("div", { className: "hsk-cb-dot" }),
|
|
@@ -2272,7 +2335,7 @@ function SparkleModal({
|
|
|
2272
2335
|
const client = useAkropolysContext4();
|
|
2273
2336
|
const [fetchedProduct, setFetchedProduct] = useState6(null);
|
|
2274
2337
|
const displayProduct = initialProduct || fetchedProduct;
|
|
2275
|
-
const { results, loading: searchLoading, search } = useSearch2();
|
|
2338
|
+
const { results, loading: searchLoading, search } = useSearch2({ type: "vector" });
|
|
2276
2339
|
const { messages, sources, loading: chatLoading, error: chatError, send } = useKiku3();
|
|
2277
2340
|
const [chatInput, setChatInput] = useState6("");
|
|
2278
2341
|
const [isMobile, setIsMobile] = useState6(false);
|