CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-langchain--core

Core LangChain.js abstractions and schemas for building applications with Large Language Models

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

documents.mddocs/

Document Processing

Document representation and processing capabilities for content management in LangChain applications. Documents are the fundamental units of text data used throughout the framework.

Capabilities

Document

Core document representation containing text content and metadata.

/**
 * Core document representation
 * @template Metadata - Type of metadata object
 */
class Document<Metadata = Record<string, unknown>> {
  /** Main text content of the document */
  pageContent: string;
  /** Associated metadata */
  metadata: Metadata;
  /** Optional unique identifier */
  id?: string;
  
  constructor(fields: DocumentInput<Metadata>);
  
  /** Convert to JSON representation */
  toJSON(): Serialized;
  
  /** Create document from JSON */
  static fromJSON(json: Serialized): Document;
}

Usage Examples:

import { Document } from "@langchain/core/documents";

// Simple document
const doc1 = new Document({
  pageContent: "LangChain is a framework for building applications with LLMs.",
  metadata: {
    source: "documentation",
    category: "introduction"
  }
});

// Document with custom metadata type
interface ArticleMetadata {
  title: string;
  author: string;
  publishDate: Date;
  tags: string[];
}

const article = new Document<ArticleMetadata>({
  pageContent: "This is the article content...",
  metadata: {
    title: "Understanding LangChain",
    author: "John Doe", 
    publishDate: new Date("2024-01-15"),
    tags: ["langchain", "llm", "tutorial"]
  },
  id: "article-123"
});

console.log(article.pageContent); // "This is the article content..."
console.log(article.metadata.title); // "Understanding LangChain"

Types

interface DocumentInput<Metadata = Record<string, unknown>> {
  /** Main text content */
  pageContent: string;
  /** Document metadata */
  metadata?: Metadata;
  /** Optional document identifier */
  id?: string;
}

interface DocumentInterface<Metadata = Record<string, unknown>> {
  pageContent: string;
  metadata: Metadata;
  id?: string;
}

docs

agents.md

caches.md

callbacks.md

documents.md

embeddings.md

index.md

language-models.md

memory-storage.md

messages.md

output-parsers.md

prompts.md

retrievers.md

runnables.md

tools.md

vectorstores.md

tile.json