List Documents langbase.memory.documents.list()

List documents in a memory on Langbase using the langbase.memory.documents.list() function.


Generate a User/Org API key

You will need to generate an API key to authenticate your requests. For more information, visit the User/Org API key documentation.


API reference

langbase.memory.documents.list(options)

Function Signature

langbase.memory.documents.list(options);

// with types.
langbase.memory.documents.list(options: MemoryListDocOptions);

options

  • Name
    options
    Type
    MemoryListDocOptions
    Description

    MemoryListDocOptions Object

    interface MemoryListDocOptions {
    	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

.env file

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!,
});

const documents = await langbase.memory.documents.list({
	memoryName: 'knowledge-base'
});

Response

  • Name
    MemoryListDocResponse[]
    Type
    array
    Description

    The response array returned by the langbase.memory.documents.list() function.

    MemoryListDocResponse

    interface 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 processed
      • in_progress: Document is currently being processed
      • completed: Document has been successfully processed
      • failed: Document processing failed
    • Name
      status_message
      Type
      string | null
      Description

      Additional details about the document's status, particularly useful when status is 'failed'.

    • Name
      metadata
      Type
      object
      Description

      Document metadata including:

      • size: Size of the document in bytes
      • type: 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.memory.documents.list()

[
	{
		"name": "product-manual.pdf",
		"status": "completed",
		"status_message": null,
		"metadata": {
			"size": 1156,
			"type": "application/pdf"
		},
		"enabled": true,
		"chunk_size": 1024,
		"chunk_overlap": 256,
		"owner_login": "user123"
	},
	{
		"name": "technical-specs.md",
		"status": "in_progress",
		"status_message": null,
		"metadata": {
			"size": 1156,
			"type": "text/markdown"
		},
		"enabled": true,
		"chunk_size": 1024,
		"chunk_overlap": 256,
		"owner_login": "user123"
	}
]