Skip to content

Commit d0d3b70

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: followup uses groups ids in group mode
1 parent b8c4846 commit d0d3b70

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

clients/search-component/src/utils/hooks/chat-context.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
139139
const [productsWithClicks, setProductsWithClicks] = useState<
140140
ChunkIdWithIndex[]
141141
>([]);
142+
const [groupIdsInChat, setGroupIdsInChat] = useState<string[]>([]);
142143

143144
const createTopic = async ({
144145
question,
@@ -573,7 +574,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
573574
});
574575

575576
const skipSearchPromise = retryOperation(async () => {
576-
if (props.type === "ecommerce" && !curGroup && messages.length > 1) {
577+
if (!curGroup && messages.length > 1) {
577578
return await trieveSDK.getToolCallFunctionParams({
578579
user_message_text: `Here's the previous message thread so far: ${messages.map(
579580
(message) => {
@@ -1031,6 +1032,8 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
10311032
],
10321033
};
10331034

1035+
setGroupIdsInChat((prev) => [...prev, ...topGroupIds]);
1036+
10341037
try {
10351038
const topImageGroupIds = topGroupIds.slice(0, 3);
10361039
const getChunksPromises = topImageGroupIds.map((groupId) =>
@@ -1151,17 +1154,25 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
11511154
createMessageFilters = filters;
11521155
}
11531156
if (skipSearch) {
1154-
createMessageFilters = {
1155-
must: [
1156-
{
1157-
field: "ids",
1158-
match_any: messages
1159-
.filter((msg) => msg.type == "system")
1160-
.flatMap((msg) => msg.additional ?? [])
1161-
.map((chunk) => chunk.id),
1162-
},
1163-
],
1164-
};
1157+
createMessageFilters = props.useGroupSearch
1158+
? {
1159+
must: [
1160+
{
1161+
field: "group_ids",
1162+
match_any: groupIdsInChat,
1163+
},
1164+
],
1165+
}
1166+
: {
1167+
must: [
1168+
{
1169+
field: "ids",
1170+
match_any: messages
1171+
.flatMap((m) => m.additional ?? [])
1172+
.map((chunk) => chunk.id),
1173+
},
1174+
],
1175+
};
11651176
}
11661177
const systemPromptToUse =
11671178
props.systemPrompt && props.systemPrompt !== ""

0 commit comments

Comments
 (0)