Skip to content

Commit aa40e35

Browse files
committed
👌 IMPROVE: Chunk options and endpoint request
1 parent e34c39b commit aa40e35

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

packages/langbase/src/langbase/langbase.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,9 @@ export interface EmbedOptions {
409409
export type EmbedResponse = number[][];
410410

411411
export interface ChunkOptions {
412-
document: Buffer | File | FormData | ReadableStream;
413-
documentName: string;
414-
contentType: ContentType;
415-
chunkMaxLength?: string;
416-
chunkOverlap?: string;
412+
content: string;
413+
chunkOverlap?: number;
414+
chunkMaxLength?: number;
417415
}
418416

419417
export type ChunkResponse = string[];
@@ -975,26 +973,10 @@ export class Langbase {
975973
* @returns A promise that resolves to the chunked document response.
976974
*/
977975
private async chunkDocument(options: ChunkOptions): Promise<ChunkResponse> {
978-
const formData = await convertDocToFormData({
979-
document: options.document,
980-
documentName: options.documentName,
981-
contentType: options.contentType,
982-
});
983-
984-
if (options.chunkMaxLength)
985-
formData.append('chunkMaxLength', options.chunkMaxLength);
986-
if (options.chunkOverlap)
987-
formData.append('chunkOverlap', options.chunkOverlap);
988-
989-
const response = await fetch(`${this.baseUrl}/v1/chunk`, {
990-
method: 'POST',
991-
headers: {
992-
Authorization: `Bearer ${this.apiKey}`,
993-
},
994-
body: formData,
976+
return this.request.post({
977+
endpoint: '/v1/chunk',
978+
body: options,
995979
});
996-
997-
return response.json();
998980
}
999981

1000982
/**

0 commit comments

Comments
 (0)