-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmemory.upload-text.ts
More file actions
37 lines (29 loc) · 1006 Bytes
/
memory.upload-text.ts
File metadata and controls
37 lines (29 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'dotenv/config';
import {Langbase} from 'langbase';
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!,
});
async function main() {
const textContent = `
# Langbase SDK Memory Upload Example
This is a sample text that demonstrates how to upload text directly to memory
without needing to handle files. This feature allows you to:
- Upload plain text content to memory
- Add metadata to the uploaded text
- Automatically generate document names or provide custom ones
This makes it easy to add content from variables, API responses, or any other text source.
`.trim();
const response = await langbase.memories.uploadText({
memoryName: 'memory-sdk',
text: textContent,
documentName: 'sdk-demo-text.txt',
meta: {
type: 'demo',
source: 'sdk-example',
description: 'Example of uploadText functionality',
},
});
console.log('Text upload response status:', response.status);
console.log('Upload successful:', response.ok);
}
main().catch(console.error);