Skip to content

Commit

Permalink
feature: add rebalance chunks to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed May 30, 2024
1 parent 1505318 commit de315d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
19 changes: 18 additions & 1 deletion search/src/components/UploadFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const UploadFile = () => {
const [timestamp, setTimestamp] = createSignal("");
const [splitDelimiters, setSplitDelimiters] = createSignal([".", "?", "\\n"]);
const [targetSplitsPerChunk, setTargetSplitsPerChunk] = createSignal(20);
const [rebalanceChunks, setRebalanceChunks] = createSignal(false);

const handleDragUpload = (e: DragEvent) => {
e.preventDefault();
Expand Down Expand Up @@ -68,6 +69,7 @@ export const UploadFile = () => {
tag_set: tagSet().split(","),
split_delimiters: splitDelimiters(),
target_splits_per_chunk: targetSplitsPerChunk(),
rebalance_chunks: rebalanceChunks(),
};

if (timestamp()) {
Expand Down Expand Up @@ -157,7 +159,7 @@ export const UploadFile = () => {
<div>Target Splits Per Chunk</div>
<Tooltip
body={<BsInfoCircle />}
tooltipText="Target splits per chunk. This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number. Trieve will evenly distribute remainder splits across chunks such that 46 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each."
tooltipText="Target splits per chunk. This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number."
/>
</div>
<input
Expand All @@ -168,6 +170,21 @@ export const UploadFile = () => {
class="w-full rounded-md border border-gray-300 bg-neutral-100 px-4 py-1 dark:bg-neutral-700"
/>
</div>
<div class="flex flex-col space-y-2">
<div class="flex flex-row items-center space-x-2">
<div>Rebalance Chunks</div>
<Tooltip
body={<BsInfoCircle />}
tooltipText="Balance chunks. If set to true, Trieve will evenly distribute remainder splits across chunks such that 46 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each."
/>
</div>
<input
type="checkbox"
checked={rebalanceChunks()}
onInput={(e) => setRebalanceChunks(e.currentTarget.checked)}
class="h-4 w-4 rounded-md border border-gray-300 bg-neutral-100 px-4 py-1 dark:bg-neutral-700"
/>
</div>
<label
for="dropzone-file"
class="dark:hover:bg-bray-800 flex h-64 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-neutral-100 hover:bg-neutral-200 dark:border-gray-600 dark:bg-neutral-700 dark:hover:border-gray-500 dark:hover:bg-gray-600"
Expand Down
2 changes: 0 additions & 2 deletions server/src/handlers/file_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ pub struct UploadFileReqPayload {
pub metadata: Option<serde_json::Value>,
/// Create chunks is a boolean which determines whether or not to create chunks from the file. If false, you can manually chunk the file and send the chunks to the create_chunk endpoint with the file_id to associate chunks with the file. Meant mostly for advanced users.
pub create_chunks: Option<bool>,

/// Rebalance chunks is an optional field which allows you to specify whether or not to rebalance the chunks created from the file. If not specified, the default false is used. If true, chunks will be reblanced to target 20 chunks per file on average.
pub rebalance_chunks: Option<bool>,

/// Split delimiters is an optional field which allows you to specify the delimiters to use when splitting the file before chunking the text. If not specified, the default [.!?\n] are used to split into sentences. However, you may want to use spaces or other delimiters.
pub split_delimiters: Option<Vec<String>>,
/// Target splits per chunk. This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number. Trieve will evenly distribute remainder splits across chunks such that 66 splits with a `target_splits_per_chunk` of 20 will result in 3 chunks with 22 splits each.
Expand Down
2 changes: 1 addition & 1 deletion server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl Modify for SecurityAddon {
name = "BSL",
url = "https://github.com/devflowinc/trieve/blob/main/LICENSE.txt",
),
version = "0.8.8",
version = "0.8.9",
),
servers(
(url = "https://api.trieve.ai",
Expand Down

0 comments on commit de315d0

Please sign in to comment.