Skip to content

Commit 3626e79

Browse files
committed
👌 IMPROVE: Change file name to document name
1 parent f1a98ed commit 3626e79

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

examples/nodejs/examples/memory/memory.docs.upload.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ async function main() {
1414
'memory',
1515
'memory.upload.doc.ts',
1616
);
17-
const file = fs.readFileSync(src);
1817

1918
const response = await langbase.memory.documents.upload({
20-
file,
19+
document: fs.readFileSync(src),
2120
memoryName: 'memory-sdk',
22-
fileName: 'memory.upload.doc.ts',
21+
documentName: 'memory.upload.doc.ts',
2322
contentType: 'text/plain',
2423
meta: {
2524
extension: 'ts',

packages/langbase/src/langbase/langbase.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export interface Variable {
4343
value: string;
4444
}
4545

46-
4746
interface ToolChoice {
4847
type: 'function';
4948
function: {name: string};
@@ -174,9 +173,9 @@ export interface MemoryDeleteDocOptions {
174173

175174
export interface MemoryUploadDocOptions {
176175
memoryName: string;
177-
fileName: string;
176+
documentName: string;
178177
meta?: Record<string, string>;
179-
file: Buffer | File | FormData | ReadableStream;
178+
document: Buffer | File | FormData | ReadableStream;
180179
contentType:
181180
| 'application/pdf'
182181
| 'text/plain'
@@ -374,7 +373,9 @@ export class Langbase {
374373
* @param {string} options.description - The description of the memory.
375374
* @returns {Promise<MemoryCreateResponse>} A promise that resolves to the response of the memory creation.
376375
*/
377-
private async createMemory(options: MemoryCreateOptions): Promise<MemoryCreateResponse> {
376+
private async createMemory(
377+
options: MemoryCreateOptions,
378+
): Promise<MemoryCreateResponse> {
378379
return this.request.post({
379380
endpoint: '/v1/memory',
380381
body: options,
@@ -399,7 +400,9 @@ export class Langbase {
399400
* @param {string} options.name - The name of the memory to delete.
400401
* @returns {Promise<MemoryDeleteResponse>} A promise that resolves to the response of the delete operation.
401402
*/
402-
private async deleteMemory(options: MemoryDeleteOptions): Promise<MemoryDeleteResponse> {
403+
private async deleteMemory(
404+
options: MemoryDeleteOptions,
405+
): Promise<MemoryDeleteResponse> {
403406
return this.request.delete({
404407
endpoint: `/v1/memory/${options.name}`,
405408
});
@@ -466,13 +469,15 @@ export class Langbase {
466469
* @returns {Promise<Response>} The response from the upload request.
467470
* @throws Will throw an error if the upload fails.
468471
*/
469-
private async uploadDocs(options: MemoryUploadDocOptions): Promise<Response> {
472+
private async uploadDocs(
473+
options: MemoryUploadDocOptions,
474+
): Promise<Response> {
470475
try {
471476
const response = (await this.request.post({
472477
endpoint: `/v1/memory/documents`,
473478
body: {
474479
memoryName: options.memoryName,
475-
fileName: options.fileName,
480+
fileName: options.documentName,
476481
meta: options.meta,
477482
},
478483
})) as unknown as {signedUrl: string};
@@ -485,7 +490,7 @@ export class Langbase {
485490
Authorization: `Bearer ${this.apiKey}`,
486491
'Content-Type': options.contentType,
487492
},
488-
body: options.file,
493+
body: options.document,
489494
});
490495
} catch (error) {
491496
throw error;

0 commit comments

Comments
 (0)