@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.js
CHANGED
|
@@ -1488,19 +1488,87 @@ 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 openTag = "<thinking>";
|
|
1493
|
+
const closeTag = "</thinking>";
|
|
1494
|
+
const openIdx = text.indexOf(openTag);
|
|
1495
|
+
if (openIdx === -1) {
|
|
1496
|
+
return { thinking: "", content: text, isComplete: true };
|
|
1497
|
+
}
|
|
1498
|
+
const start = openIdx + openTag.length;
|
|
1499
|
+
const closeIdx = text.indexOf(closeTag, start);
|
|
1500
|
+
if (closeIdx === -1) {
|
|
1501
|
+
return { thinking: text.slice(start), content: "", isComplete: false };
|
|
1502
|
+
}
|
|
1503
|
+
return {
|
|
1504
|
+
thinking: text.slice(start, closeIdx),
|
|
1505
|
+
content: text.slice(closeIdx + closeTag.length),
|
|
1506
|
+
isComplete: true
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
function ThinkingBlock({ text, isComplete }) {
|
|
1510
|
+
const [isOpen, setIsOpen] = (0, import_react5.useState)(true);
|
|
1511
|
+
(0, import_react5.useEffect)(() => {
|
|
1512
|
+
if (!isComplete) {
|
|
1513
|
+
setIsOpen(true);
|
|
1514
|
+
}
|
|
1515
|
+
}, [isComplete]);
|
|
1516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
|
|
1517
|
+
marginBottom: "12px",
|
|
1518
|
+
borderLeft: "2px solid #e4e4e7",
|
|
1519
|
+
paddingLeft: "10px",
|
|
1520
|
+
fontSize: "0.825rem",
|
|
1521
|
+
backgroundColor: "rgba(244, 244, 245, 0.4)",
|
|
1522
|
+
padding: "8px 10px",
|
|
1523
|
+
borderRadius: "0 6px 6px 0"
|
|
1524
|
+
}, children: [
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1526
|
+
"div",
|
|
1527
|
+
{
|
|
1528
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1529
|
+
style: {
|
|
1530
|
+
display: "flex",
|
|
1531
|
+
alignItems: "center",
|
|
1532
|
+
gap: "6px",
|
|
1533
|
+
color: "#71717a",
|
|
1534
|
+
cursor: "pointer",
|
|
1535
|
+
fontWeight: 500,
|
|
1536
|
+
userSelect: "none"
|
|
1537
|
+
},
|
|
1538
|
+
children: [
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
|
|
1540
|
+
/* @__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: [
|
|
1541
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1542
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 6v6l4 2" })
|
|
1543
|
+
] }),
|
|
1544
|
+
"Thinking Process"
|
|
1545
|
+
] }),
|
|
1546
|
+
!isComplete && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
|
|
1547
|
+
width: "6px",
|
|
1548
|
+
height: "6px",
|
|
1549
|
+
borderRadius: "50%",
|
|
1550
|
+
backgroundColor: "#3b82f6",
|
|
1551
|
+
display: "inline-block",
|
|
1552
|
+
animation: "hsk-pulse 1.2s infinite ease-in-out"
|
|
1553
|
+
} }),
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
|
|
1555
|
+
fontSize: "0.7rem",
|
|
1556
|
+
marginLeft: "auto",
|
|
1557
|
+
transform: isOpen ? "rotate(90deg)" : "none",
|
|
1558
|
+
transition: "transform 0.1s"
|
|
1559
|
+
}, children: "\u25B6" })
|
|
1560
|
+
]
|
|
1561
|
+
}
|
|
1562
|
+
),
|
|
1563
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1564
|
+
marginTop: "6px",
|
|
1565
|
+
color: "#52525b",
|
|
1566
|
+
whiteSpace: "pre-wrap",
|
|
1567
|
+
lineHeight: "1.4",
|
|
1568
|
+
fontStyle: "italic"
|
|
1569
|
+
}, children: text })
|
|
1570
|
+
] });
|
|
1571
|
+
}
|
|
1504
1572
|
var PROPERTY_CHIPS = [
|
|
1505
1573
|
"3 bedroom apartments",
|
|
1506
1574
|
"Houses under KSh 5,000,000",
|
|
@@ -1525,7 +1593,6 @@ function ChatModal({
|
|
|
1525
1593
|
const client = (0, import_sdk6.useAkropolysContext)();
|
|
1526
1594
|
const { messages, sources, loading, streaming, error, lastAction, lastIntent, send, reset, referencedIds } = (0, import_sdk4.useKiku)();
|
|
1527
1595
|
const [input, setInput] = (0, import_react5.useState)("");
|
|
1528
|
-
const [loadingMessageIndex, setLoadingMessageIndex] = (0, import_react5.useState)(0);
|
|
1529
1596
|
const [attachments, setAttachments] = (0, import_react5.useState)([]);
|
|
1530
1597
|
const imageInputRef = (0, import_react5.useRef)(null);
|
|
1531
1598
|
const handleImageFiles = (files) => {
|
|
@@ -1581,16 +1648,6 @@ function ChatModal({
|
|
|
1581
1648
|
const activeChips = chips === DEFAULT_CHIPS && isProperty ? PROPERTY_CHIPS : chips;
|
|
1582
1649
|
const activeTitle = title === "Shopping Assistant" && isProperty ? "Property Assistant" : title;
|
|
1583
1650
|
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
1651
|
const [selectedProduct, setSelectedProduct] = (0, import_react5.useState)(null);
|
|
1595
1652
|
const bottomRef = (0, import_react5.useRef)(null);
|
|
1596
1653
|
const textareaRef = (0, import_react5.useRef)(null);
|
|
@@ -1861,7 +1918,13 @@ function ChatModal({
|
|
|
1861
1918
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-msg", children: [
|
|
1862
1919
|
/* @__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
1920
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-ai-body", children: [
|
|
1864
|
-
|
|
1921
|
+
(() => {
|
|
1922
|
+
const { thinking, content, isComplete } = parseThinking(displayContent);
|
|
1923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1924
|
+
thinking && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ThinkingBlock, { text: thinking, isComplete }),
|
|
1925
|
+
content && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-ai-text", children: renderMarkdown(content) })
|
|
1926
|
+
] });
|
|
1927
|
+
})(),
|
|
1865
1928
|
isLast && lastIntent === "compare" && sources.length >= 2 && !replayMessages && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ComparisonMatrix, { sources, defaultCurrency }),
|
|
1866
1929
|
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
1930
|
SourcesCarousel,
|
|
@@ -1927,7 +1990,7 @@ function ChatModal({
|
|
|
1927
1990
|
50% { opacity: 1; }
|
|
1928
1991
|
}
|
|
1929
1992
|
` }),
|
|
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:
|
|
1993
|
+
/* @__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
1994
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hsk-cb-typing", style: { margin: 0, alignSelf: "flex-start" }, children: [
|
|
1932
1995
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-dot" }),
|
|
1933
1996
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hsk-cb-dot" }),
|
|
@@ -2307,7 +2370,7 @@ function SparkleModal({
|
|
|
2307
2370
|
const client = (0, import_sdk7.useAkropolysContext)();
|
|
2308
2371
|
const [fetchedProduct, setFetchedProduct] = (0, import_react6.useState)(null);
|
|
2309
2372
|
const displayProduct = initialProduct || fetchedProduct;
|
|
2310
|
-
const { results, loading: searchLoading, search } = (0, import_sdk7.useSearch)();
|
|
2373
|
+
const { results, loading: searchLoading, search } = (0, import_sdk7.useSearch)({ type: "vector" });
|
|
2311
2374
|
const { messages, sources, loading: chatLoading, error: chatError, send } = (0, import_sdk7.useKiku)();
|
|
2312
2375
|
const [chatInput, setChatInput] = (0, import_react6.useState)("");
|
|
2313
2376
|
const [isMobile, setIsMobile] = (0, import_react6.useState)(false);
|