@hivegpt/hiveai-angular 0.0.433 → 0.0.435
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/bundles/hivegpt-hiveai-angular.umd.js +122 -29
- package/bundles/hivegpt-hiveai-angular.umd.js.map +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js.map +1 -1
- package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +123 -30
- package/fesm2015/hivegpt-hiveai-angular.js +122 -29
- package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
- package/hivegpt-hiveai-angular.metadata.json +1 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts +7 -0
- package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1654,6 +1654,54 @@ class ChatDrawerComponent {
|
|
|
1654
1654
|
});
|
|
1655
1655
|
});
|
|
1656
1656
|
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Parse get_event_sessions_v2 plain-text content into session objects for cards.
|
|
1659
|
+
* Format: "Found N sessions:\n1. <title>\n - Time: Start: ..., End: ..., TimeZone: ...\n - Room: ...\n - Type: ...\n2. ..."
|
|
1660
|
+
*/
|
|
1661
|
+
parseSessionContentV2(content) {
|
|
1662
|
+
if (!content || typeof content !== 'string')
|
|
1663
|
+
return [];
|
|
1664
|
+
const sessions = [];
|
|
1665
|
+
// Split into blocks by "1. ", "2. ", etc. (number + dot + space at line start)
|
|
1666
|
+
const blockRegex = /\n\d+\.\s+/;
|
|
1667
|
+
const parts = content.split(blockRegex);
|
|
1668
|
+
// First part may be "Found N sessions:" or similar; skip if it doesn't look like a session title
|
|
1669
|
+
for (let i = 0; i < parts.length; i++) {
|
|
1670
|
+
const block = parts[i].trim();
|
|
1671
|
+
if (!block)
|
|
1672
|
+
continue;
|
|
1673
|
+
const lines = block.split(/\n/).map((l) => l.trim()).filter(Boolean);
|
|
1674
|
+
const title = lines[0] || '';
|
|
1675
|
+
if (!title || /^Found\s+\d+\s+sessions/i.test(title))
|
|
1676
|
+
continue;
|
|
1677
|
+
let dateTimeRange = '';
|
|
1678
|
+
let roomName = '';
|
|
1679
|
+
let sessionType = '';
|
|
1680
|
+
for (let j = 1; j < lines.length; j++) {
|
|
1681
|
+
const line = lines[j];
|
|
1682
|
+
const timeMatch = line.match(/Time:\s*(.+)/i);
|
|
1683
|
+
if (timeMatch) {
|
|
1684
|
+
dateTimeRange = timeMatch[1].trim();
|
|
1685
|
+
}
|
|
1686
|
+
const roomMatch = line.match(/Room:\s*(.+)/i);
|
|
1687
|
+
if (roomMatch) {
|
|
1688
|
+
roomName = roomMatch[1].trim();
|
|
1689
|
+
}
|
|
1690
|
+
const typeMatch = line.match(/Type:\s*(.+)/i);
|
|
1691
|
+
if (typeMatch) {
|
|
1692
|
+
sessionType = typeMatch[1].trim();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
sessions.push({
|
|
1696
|
+
title,
|
|
1697
|
+
roomName: roomName || undefined,
|
|
1698
|
+
dateTimeRange: dateTimeRange || undefined,
|
|
1699
|
+
sessionType: sessionType || undefined,
|
|
1700
|
+
sessionRoles: [],
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
return sessions;
|
|
1704
|
+
}
|
|
1657
1705
|
getVisibleSessionCards(chat) {
|
|
1658
1706
|
var _a;
|
|
1659
1707
|
const list = (_a = chat === null || chat === void 0 ? void 0 : chat.sessionCards) !== null && _a !== void 0 ? _a : [];
|
|
@@ -1729,15 +1777,25 @@ class ChatDrawerComponent {
|
|
|
1729
1777
|
else if ((_k = res === null || res === void 0 ? void 0 : res.m) === null || _k === void 0 ? void 0 : _k.OtherFields) {
|
|
1730
1778
|
const otherFields = res.m.OtherFields;
|
|
1731
1779
|
const serializable = otherFields.serializable_to_return;
|
|
1732
|
-
// Session cards:
|
|
1733
|
-
|
|
1780
|
+
// Session cards: get_event_sessions (JSON) or get_event_sessions_v2 (JSON or plain text)
|
|
1781
|
+
const isSessionTool = (serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_sessions' ||
|
|
1782
|
+
(serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_sessions_v2';
|
|
1783
|
+
if (isSessionTool) {
|
|
1734
1784
|
const contentStr = (_o = (_m = (_l = serializable === null || serializable === void 0 ? void 0 : serializable.tool_result) === null || _l === void 0 ? void 0 : _l.messages) === null || _m === void 0 ? void 0 : _m[0]) === null || _o === void 0 ? void 0 : _o.content;
|
|
1735
1785
|
const answerText = otherFields.answer != null ? String(otherFields.answer).trim() : '';
|
|
1736
|
-
|
|
1786
|
+
let pushed = false;
|
|
1787
|
+
if (contentStr && typeof contentStr === 'string') {
|
|
1788
|
+
let sessions = [];
|
|
1737
1789
|
try {
|
|
1738
1790
|
const parsed = JSON.parse(contentStr);
|
|
1739
|
-
|
|
1740
|
-
|
|
1791
|
+
sessions = (_p = parsed === null || parsed === void 0 ? void 0 : parsed.sessions) !== null && _p !== void 0 ? _p : [];
|
|
1792
|
+
}
|
|
1793
|
+
catch (e) {
|
|
1794
|
+
// v2 plain text: "Found 2 sessions:\n1. Title\n - Time: Start: ... End: ...\n - Room: ...\n - Type: ..."
|
|
1795
|
+
sessions = this.parseSessionContentV2(contentStr);
|
|
1796
|
+
}
|
|
1797
|
+
const mapped = this.mapSessionsToCardData(sessions);
|
|
1798
|
+
if (mapped.length > 0) {
|
|
1741
1799
|
this.chatLog.push({
|
|
1742
1800
|
_id: serializable.message_id || `session_cards_${Date.now()}`,
|
|
1743
1801
|
type: 'session_cards',
|
|
@@ -1748,14 +1806,14 @@ class ChatDrawerComponent {
|
|
|
1748
1806
|
this.showFeedBackIconsIndex = this.chatLog.length - 1;
|
|
1749
1807
|
this.isChatingWithAi = false;
|
|
1750
1808
|
this.scrollToBottom();
|
|
1751
|
-
|
|
1752
|
-
}
|
|
1753
|
-
catch (e) {
|
|
1754
|
-
console.error('[Socket Chat] Error parsing get_event_sessions content:', e);
|
|
1809
|
+
pushed = true;
|
|
1755
1810
|
}
|
|
1756
1811
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1812
|
+
if (pushed) {
|
|
1813
|
+
this.cdr.markForCheck();
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
// No session cards pushed: fall through to normal OtherFields handling so answer is displayed
|
|
1759
1817
|
}
|
|
1760
1818
|
// Attendee cards: tool get_event_attendees (same as React Native)
|
|
1761
1819
|
if ((serializable === null || serializable === void 0 ? void 0 : serializable.tool_name) === 'get_event_attendees') {
|
|
@@ -2013,6 +2071,27 @@ class ChatDrawerComponent {
|
|
|
2013
2071
|
// })
|
|
2014
2072
|
// );
|
|
2015
2073
|
// }
|
|
2074
|
+
/** Push a standard AI message from history (sources, graphs, etc.). Used when not converting to session_cards. */
|
|
2075
|
+
pushAiMessageFromHistory(chat) {
|
|
2076
|
+
const sourcesList = chat.WebLinks || [];
|
|
2077
|
+
const displayedSources = (chat.WebLinks || []).slice(0, 3);
|
|
2078
|
+
const remainingSources = (chat.WebLinks || []).slice(3);
|
|
2079
|
+
this.chatLog.push({
|
|
2080
|
+
type: 'ai',
|
|
2081
|
+
message: this.processMessageForDisplay(chat.Text),
|
|
2082
|
+
executionGraphs: chat.ExecutionGraphs,
|
|
2083
|
+
graphs: chat.Graphs,
|
|
2084
|
+
searchTerms: chat.SearchTerms,
|
|
2085
|
+
sourcesList: sourcesList,
|
|
2086
|
+
displayedSources: displayedSources,
|
|
2087
|
+
remainingSources: remainingSources,
|
|
2088
|
+
time: formatTimeStamps(this.timezone, chat.InsertTimestamp),
|
|
2089
|
+
copied: false,
|
|
2090
|
+
isCollapsedTrue: false,
|
|
2091
|
+
_id: chat._id,
|
|
2092
|
+
});
|
|
2093
|
+
this.showFeedBackIconsIndex = this.chatLog.length - 1;
|
|
2094
|
+
}
|
|
2016
2095
|
mapChatHistory(chats) {
|
|
2017
2096
|
var _a;
|
|
2018
2097
|
this.chatLog.push({
|
|
@@ -2022,6 +2101,7 @@ class ChatDrawerComponent {
|
|
|
2022
2101
|
});
|
|
2023
2102
|
if (chats && ((_a = chats === null || chats === void 0 ? void 0 : chats.Messages) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2024
2103
|
chats === null || chats === void 0 ? void 0 : chats.Messages.forEach((chat) => {
|
|
2104
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2025
2105
|
if (chat.Type == 'user') {
|
|
2026
2106
|
this.chatLog.push({
|
|
2027
2107
|
type: 'user',
|
|
@@ -2034,24 +2114,37 @@ class ChatDrawerComponent {
|
|
|
2034
2114
|
});
|
|
2035
2115
|
}
|
|
2036
2116
|
if (chat.Type == 'ai') {
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2117
|
+
// If this AI message came from get_event_sessions / get_event_sessions_v2, show session cards instead of plain text
|
|
2118
|
+
const toolName = (_a = chat.toolresults) === null || _a === void 0 ? void 0 : _a.tool_name;
|
|
2119
|
+
const isSessionTool = toolName === 'get_event_sessions' || toolName === 'get_event_sessions_v2';
|
|
2120
|
+
if (isSessionTool && ((_e = (_d = (_c = (_b = chat.toolresults) === null || _b === void 0 ? void 0 : _b.tool_result) === null || _c === void 0 ? void 0 : _c.messages) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.content)) {
|
|
2121
|
+
const contentStr = chat.toolresults.tool_result.messages[0].content;
|
|
2122
|
+
let sessions = [];
|
|
2123
|
+
try {
|
|
2124
|
+
const parsed = JSON.parse(contentStr);
|
|
2125
|
+
sessions = (_f = parsed === null || parsed === void 0 ? void 0 : parsed.sessions) !== null && _f !== void 0 ? _f : [];
|
|
2126
|
+
}
|
|
2127
|
+
catch (e) {
|
|
2128
|
+
sessions = this.parseSessionContentV2(contentStr);
|
|
2129
|
+
}
|
|
2130
|
+
const mapped = this.mapSessionsToCardData(sessions);
|
|
2131
|
+
if (mapped.length > 0) {
|
|
2132
|
+
this.chatLog.push({
|
|
2133
|
+
_id: chat._id,
|
|
2134
|
+
type: 'session_cards',
|
|
2135
|
+
message: chat.Text ? this.processMessageForDisplay(chat.Text) : '',
|
|
2136
|
+
time: formatTimeStamps(this.timezone, chat.InsertTimestamp),
|
|
2137
|
+
sessionCards: mapped,
|
|
2138
|
+
});
|
|
2139
|
+
this.showFeedBackIconsIndex = this.chatLog.length - 1;
|
|
2140
|
+
}
|
|
2141
|
+
else {
|
|
2142
|
+
this.pushAiMessageFromHistory(chat);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
else {
|
|
2146
|
+
this.pushAiMessageFromHistory(chat);
|
|
2147
|
+
}
|
|
2055
2148
|
}
|
|
2056
2149
|
});
|
|
2057
2150
|
this.showStartAgain = true;
|