Skip to content

Commit e06f169

Browse files
committed
feature: remove description on groups view in favor of Chunk Count on
group page
1 parent ddb7efc commit e06f169

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

clients/ts-sdk/openapi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10698,7 +10698,8 @@
1069810698
},
1069910699
"total_pages": {
1070010700
"type": "integer",
10701-
"format": "int32"
10701+
"format": "int32",
10702+
"minimum": 0
1070210703
}
1070310704
}
1070410705
},

frontends/search/src/components/OrgGroupPageView.tsx

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { FiTrash } from "solid-icons/fi";
2-
import { isChunkGroupPageDTO, type ChunkGroupDTO } from "../utils/apiTypes";
2+
import {
3+
indirectHasOwnProperty,
4+
isChunkGroupPageDTO,
5+
type ChunkGroupDTO,
6+
} from "../utils/apiTypes";
37
import {
48
For,
59
Setter,
@@ -20,20 +24,76 @@ export interface GroupUserPageViewProps {
2024
setShowConfirmModal: Setter<boolean>;
2125
}
2226

27+
export type GetChunkGroupCountResponse = {
28+
count: number;
29+
group_id: string;
30+
};
31+
2332
export const GroupUserPageView = (props: GroupUserPageViewProps) => {
2433
const apiHost = import.meta.env.VITE_API_HOST as string;
2534
const datasetAndUserContext = useContext(DatasetAndUserContext);
2635

2736
const $dataset = datasetAndUserContext.currentDataset;
2837
const $user = datasetAndUserContext.user;
2938
const [groups, setGroups] = createSignal<ChunkGroupDTO[]>([]);
39+
const [groupCounts, setGroupCounts] = createSignal<
40+
GetChunkGroupCountResponse[]
41+
>([]);
3042
const [groupPage, setGroupPage] = createSignal(1);
3143
const [groupPageCount, setGroupPageCount] = createSignal(1);
3244
const [deleting, setDeleting] = createSignal(false);
3345
const [loading, setLoading] = createSignal(true);
3446

3547
const serverConfig = useDatasetServerConfig();
3648

49+
createEffect(() => {
50+
const currentDataset = $dataset?.();
51+
if (!currentDataset) return;
52+
53+
const all_counts = groups().map(async (group) => {
54+
const response = await fetch(`${apiHost}/chunk_group/count`, {
55+
method: "POST",
56+
credentials: "include",
57+
body: JSON.stringify({ group_id: group.id }),
58+
headers: {
59+
"X-API-version": "2.0",
60+
"TR-Dataset": currentDataset.dataset.id,
61+
"Content-Type": "application/json",
62+
},
63+
});
64+
65+
if (response.ok) {
66+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
67+
const data = await response.json();
68+
console.log("data", data);
69+
if (
70+
data !== null &&
71+
typeof data === "object" &&
72+
indirectHasOwnProperty(data, "count") &&
73+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
74+
typeof data.count === "number" &&
75+
indirectHasOwnProperty(data, "group_id") &&
76+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
77+
typeof data.group_id === "string"
78+
) {
79+
console.log("Invalid response", data);
80+
return {
81+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
82+
group_id: data.group_id,
83+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
84+
count: data.count,
85+
} as GetChunkGroupCountResponse;
86+
}
87+
}
88+
});
89+
90+
void Promise.all(all_counts).then((counts) => {
91+
const filteredGroupCounts = counts.filter((c) => c !== undefined);
92+
console.log("setGroupCounts", filteredGroupCounts);
93+
setGroupCounts(filteredGroupCounts);
94+
});
95+
});
96+
3797
createEffect(() => {
3898
const userId = $user?.()?.id;
3999
if (userId === undefined) return;
@@ -149,7 +209,7 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
149209
scope="col"
150210
class="px-3 py-3.5 text-left text-base font-semibold dark:text-white"
151211
>
152-
Description
212+
Chunk Count
153213
</th>
154214
<th
155215
scope="col"
@@ -181,7 +241,10 @@ export const GroupUserPageView = (props: GroupUserPageViewProps) => {
181241
</a>
182242
</td>
183243
<td class="whitespace-nowrap text-wrap px-3 py-4 text-sm text-gray-900 dark:text-gray-300">
184-
{group.description}
244+
{
245+
groupCounts().find((c) => c.group_id == group.id)
246+
?.count
247+
}
185248
</td>
186249
<td class="whitespace-nowrap px-3 py-4 text-left text-sm text-gray-900 dark:text-gray-300">
187250
{getLocalTime(group.created_at).toLocaleDateString() +

frontends/search/src/components/UploadFile.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ export const UploadFile = () => {
138138
});
139139

140140
const requestBodyTemplate: Omit<RequestBody, "base64_file" | "file_name"> =
141-
{
142-
link: link() === "" ? undefined : link(),
143-
tag_set:
144-
tagSet().split(",").length > 0 ? undefined : tagSet().split(","),
145-
split_delimiters: splitDelimiters(),
146-
target_splits_per_chunk: targetSplitsPerChunk(),
147-
rebalance_chunks: rebalanceChunks(),
148-
use_pdf2md_ocr: useGptChunking(),
149-
group_tracking_id:
150-
groupTrackingId() === "" ? undefined : groupTrackingId(),
151-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
152-
metadata: metadata(),
153-
time_stamp: timestamp() ? timestamp() + " 00:00:00" : undefined,
154-
};
141+
{
142+
link: link() === "" ? undefined : link(),
143+
tag_set:
144+
tagSet().split(",").length > 0 ? undefined : tagSet().split(","),
145+
split_delimiters: splitDelimiters(),
146+
target_splits_per_chunk: targetSplitsPerChunk(),
147+
rebalance_chunks: rebalanceChunks(),
148+
use_pdf2md_ocr: useGptChunking(),
149+
group_tracking_id:
150+
groupTrackingId() === "" ? undefined : groupTrackingId(),
151+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
152+
metadata: metadata(),
153+
time_stamp: timestamp() ? timestamp() + " 00:00:00" : undefined,
154+
};
155155

156156
const uploadFilePromises = files().map(async (file) => {
157157
let base64File = await toBase64(file);
@@ -343,10 +343,11 @@ export const UploadFile = () => {
343343
</Show>
344344
<div class="m-1 mb-1 flex flex-row gap-2">
345345
<button
346-
class={`rounded border-2 border-magenta p-2 px-4 font-semibold ${showFileInput()
346+
class={`rounded border-2 border-magenta p-2 px-4 font-semibold ${
347+
showFileInput()
347348
? "bg-magenta-600 text-white"
348349
: "text-magenta hover:bg-magenta-500 hover:text-white"
349-
}`}
350+
}`}
350351
onClick={() => {
351352
setFiles([]);
352353
setShowFileInput(true);
@@ -356,10 +357,11 @@ export const UploadFile = () => {
356357
Select Files
357358
</button>
358359
<button
359-
class={`rounded border-2 border-magenta p-2 px-4 font-semibold ${showFolderInput()
360+
class={`rounded border-2 border-magenta p-2 px-4 font-semibold ${
361+
showFolderInput()
360362
? "bg-magenta-600 text-white"
361363
: "text-magenta hover:bg-magenta-500 hover:text-white"
362-
}`}
364+
}`}
363365
onClick={() => {
364366
setFiles([]);
365367
setShowFolderInput(true);

0 commit comments

Comments
 (0)