List Documents langbase.memories.documents.list()
List documents in a memory on Langbase using the langbase.memories.documents.list() function.
You will need to generate an API key to authenticate your requests. For more information, visit the User/Org API key documentation.
API reference
Function Signature
langbase.memories.documents.list(options);
// with types.
langbase.memories.documents.list(options: MemoryListDocOptions);
- Name
options- Type
- MemoryListDocOptions
- Description
MemoryListDocOptions Object
memoryName: string;Following are the properties of the options object.
- Name
memoryName- Type
- string
- Required
- Required
- Description
The memory name.
Usage example
Install the SDK
npm i langbase
Environment variables
Environment variables
LANGBASE_API_KEY="<USER/ORG-API-KEY>"
List documents
List documents in a memory
import {Langbase} from 'langbase';
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!,
});
async function main() {
const documents = await langbase.memories.documents.list({
memoryName: 'knowledge-base'
});
console.log('Documents:', documents);
}
main();
- Name
MemoryListDocResponse[]- Type
- array
- Description
The response array returned by the
langbase.memories.documents.list()function.MemoryListDocResponse
name: string; status: 'queued' | 'in_progress' | 'completed' | 'failed'; status_message: string | null; metadata: { size: number; type: | 'application/pdf' | 'text/plain' | 'text/markdown' | 'text/csv' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.ms-excel'; }; enabled: boolean; chunk_size: number; chunk_overlap: number; owner_login: string;- Name
name- Type
- string
- Description
Name of the document.
- Name
status- Type
- string
- Description
Current processing status of the document. Can be one of:
queued: Document is waiting to be processedin_progress: Document is currently being processedcompleted: Document has been successfully processedfailed: Document processing failed
- Name
status_message- Type
- string | null
- Description
Additional details about the document's status, particularly useful when the status is 'failed'.
- Name
metadata- Type
- object
- Description
Document metadata including:
size: Size of the document in bytestype: MIME type of the document
- Name
enabled- Type
- boolean
- Description
Whether the document is enabled for retrieval.
- Name
chunk_size- Type
- number
- Description
Size of text chunks used for document processing.
- Name
chunk_overlap- Type
- number
- Description
Overlap size between consecutive text chunks.
- Name
owner_login- Type
- string
- Description
Login of the document owner.
Response of langbase.memories.documents.list()
[
{
"name": "technical-doc.pdf",
"status": "completed",
"status_message": null,
"metadata": {
"size": 1156,
"type": "application/pdf"
},
"enabled": true,
"chunk_size": 10000,
"chunk_overlap": 2048,
"owner_login": "user123"
},
{
"name": "product-manual.pdf",
"status": "completed",
"status_message": null,
"metadata": {
"size": 1156,
"type": "application/pdf"
},
"enabled": true,
"chunk_size": 10000,
"chunk_overlap": 2048,
"owner_login": "user123"
},
{
"name": "technical-specs.md",
"status": "in_progress",
"status_message": null,
"metadata": {
"size": 1156,
"type": "text/markdown"
},
"enabled": true,
"chunk_size": 10000,
"chunk_overlap": 2048,
"owner_login": "user123"
}
]