LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/corecallbacksmanagerCallbackManager
Classā—Since v1.0

CallbackManager

Copy
class CallbackManager

Bases

BaseCallbackManager

Example

Copy
const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");

// Example of using LLMChain with OpenAI and a simple prompt
const chain = new LLMChain({
  llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0.9 }),
  prompt,
});

// Running the chain with a single question
const result = await chain.call({
  question: "What is the airspeed velocity of an unladen swallow?",
});
console.log("The answer is:", result);

Constructors

constructor
constructor

Properties

property
_parentRunId: string
property
handlers: BaseCallbackHandler[]
property
inheritableHandlers: BaseCallbackHandler[]
property
inheritableMetadata: Record<string, unknown>
property
inheritableTags: string[]
property
metadata: Record<string, unknown>
property
name: string
property
tags: string[]

Methods

method
addHandler
method
addMetadata
method
addTags
method
copy→ BaseCallbackHandler
method
getParentRunId→ string | undefined

Gets the parent run ID, if any.

method
handleChainStart→ any

Called at the start of a Chain run, with the chain name and inputs and the run ID.

method
handleChatModelStart→ any

Called at the start of a Chat Model run, with the prompt(s) and the run ID.

method
handleCustomEvent→ any
method
handleLLMStart→ any

Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.

method
handleRetrieverStart→ any
method
handleToolStart→ any

Called at the start of a Tool run, with the tool name and input and the run ID.

method
removeHandler
method
removeMetadata
method
removeTags
method
setHandler
method
setHandlers
method
_configureSync→ CallbackManager | undefined
method
configure→ CallbackManager | undefined
method
fromHandlers→ CallbackManager

Inherited fromBaseCallbackManager

Methods

MaddHandlerMremoveHandlerMsetHandlerMsetHandlers
View source on GitHub