Skip to content

Commit

Permalink
fix: invert logic of split_avg
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-harris committed Jan 8, 2025
1 parent abbd95d commit b245fef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clients/ts-sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -16963,7 +16963,7 @@
},
"split_avg": {
"type": "boolean",
"description": "Split average will automatically split your file into multiple chunks. Default is true. Explititly disabling this will cause each file to only produce a single chunk.",
"description": "Split average will automatically split your file into multiple chunks and average all of the resulting vectors into a single output chunk. Default is false. Explicitly enabling this will cause each file to only produce a single chunk.",
"nullable": true
},
"split_delimiters": {
Expand Down
2 changes: 1 addition & 1 deletion clients/ts-sdk/src/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3397,7 +3397,7 @@ export type UploadFileReqPayload = {
*/
rebalance_chunks?: (boolean) | null;
/**
* Split average will automatically split your file into multiple chunks. Default is true. Explititly disabling this will cause each file to only produce a single chunk.
* Split average will automatically split your file into multiple chunks and average all of the resulting vectors into a single output chunk. Default is false. Explicitly enabling this will cause each file to only produce a single chunk.
*/
split_avg?: (boolean) | null;
/**
Expand Down
6 changes: 3 additions & 3 deletions server/src/bin/file-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,10 @@ async fn upload_file(
.await?;

// If chunk splitting turned off, create only a single chunk using html_content
if !file_worker_message
if file_worker_message
.upload_file_data
.split_avg
.unwrap_or(true)
.unwrap_or(false)
{
let chunk = ChunkReqPayload {
chunk_html: Some(html_content.clone()),
Expand All @@ -666,7 +666,7 @@ async fn upload_file(
upsert_by_tracking_id: None,
time_stamp: file_worker_message.upload_file_data.time_stamp.clone(),
weight: None,
split_avg: None,
split_avg: Some(true),
convert_html_to_text: None,
image_urls: None,
num_value: None,
Expand Down
4 changes: 2 additions & 2 deletions server/src/handlers/file_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub struct UploadFileReqPayload {
pub group_tracking_id: Option<String>,
/// Parameter to use pdf2md_ocr. If true, the file will be converted to markdown using gpt-4o. Default is false.
pub pdf2md_options: Option<Pdf2MdOptions>,
/// Split average will automatically split your file into multiple chunks. Default is true. Explititly disabling this will cause each file to only produce a single chunk.
/// Split average will automatically split your file into multiple chunks and average all of the resulting vectors into a single output chunk. Default is false. Explicitly enabling this will cause each file to only produce a single chunk.
pub split_avg: Option<bool>,
}

Expand Down Expand Up @@ -138,7 +138,7 @@ pub async fn upload_file_handler(
.map_err(|err| ServiceError::BadRequest(err.to_string()))?;

// Disallow split_avg with pdf2md
if data.pdf2md_options.is_some() && !data.split_avg.unwrap_or(true) {
if data.pdf2md_options.is_some() && data.split_avg.unwrap_or(false) {
return Err(
ServiceError::BadRequest("split_avg is not supported with pdf2md".to_string()).into(),
);
Expand Down

0 comments on commit b245fef

Please sign in to comment.