@langchain/core
Advanced tools
Comparing version 0.1.29 to 0.1.30
@@ -31,2 +31,3 @@ import { KVMap, BaseRun } from "langsmith/schemas"; | ||
copy(): this; | ||
protected stringifyError(error: unknown): string; | ||
protected abstract persistRun(run: Run): Promise<void>; | ||
@@ -40,3 +41,3 @@ protected _addChildRun(parentRun: Run, childRun: Run): void; | ||
handleLLMEnd(output: LLMResult, runId: string): Promise<Run>; | ||
handleLLMError(error: Error, runId: string): Promise<Run>; | ||
handleLLMError(error: unknown, runId: string): Promise<Run>; | ||
handleChainStart(chain: Serialized, inputs: ChainValues, runId: string, parentRunId?: string, tags?: string[], metadata?: KVMap, runType?: string, name?: string): Promise<Run>; | ||
@@ -46,3 +47,3 @@ handleChainEnd(outputs: ChainValues, runId: string, _parentRunId?: string, _tags?: string[], kwargs?: { | ||
}): Promise<Run>; | ||
handleChainError(error: Error, runId: string, _parentRunId?: string, _tags?: string[], kwargs?: { | ||
handleChainError(error: unknown, runId: string, _parentRunId?: string, _tags?: string[], kwargs?: { | ||
inputs?: Record<string, unknown>; | ||
@@ -52,3 +53,3 @@ }): Promise<Run>; | ||
handleToolEnd(output: string, runId: string): Promise<Run>; | ||
handleToolError(error: Error, runId: string): Promise<Run>; | ||
handleToolError(error: unknown, runId: string): Promise<Run>; | ||
handleAgentAction(action: AgentAction, runId: string): Promise<void>; | ||
@@ -58,3 +59,3 @@ handleAgentEnd(action: AgentFinish, runId: string): Promise<void>; | ||
handleRetrieverEnd(documents: Document<Record<string, unknown>>[], runId: string): Promise<Run>; | ||
handleRetrieverError(error: Error, runId: string): Promise<Run>; | ||
handleRetrieverError(error: unknown, runId: string): Promise<Run>; | ||
handleText(text: string, runId: string): Promise<void>; | ||
@@ -61,0 +62,0 @@ handleLLMNewToken(token: string, idx: NewTokenIndices, runId: string, _parentRunId?: string, _tags?: string[], fields?: HandleLLMNewTokenCallbackFields): Promise<Run>; |
@@ -28,2 +28,12 @@ import { BaseCallbackHandler, } from "../callbacks/base.js"; | ||
} | ||
stringifyError(error) { | ||
// eslint-disable-next-line no-instanceof/no-instanceof | ||
if (error instanceof Error) { | ||
return error.message + (error?.stack ? `\n\n${error.stack}` : ""); | ||
} | ||
if (typeof error === "string") { | ||
return error; | ||
} | ||
return `${error}`; | ||
} | ||
_addChildRun(parentRun, childRun) { | ||
@@ -166,3 +176,3 @@ parentRun.child_runs.push(childRun); | ||
run.end_time = Date.now(); | ||
run.error = error.message; | ||
run.error = this.stringifyError(error); | ||
run.events.push({ | ||
@@ -227,3 +237,3 @@ name: "error", | ||
run.end_time = Date.now(); | ||
run.error = error.message + (error?.stack ? `\n\n${error.stack}` : ""); | ||
run.error = this.stringifyError(error); | ||
run.events.push({ | ||
@@ -288,3 +298,3 @@ name: "error", | ||
run.end_time = Date.now(); | ||
run.error = error.message; | ||
run.error = this.stringifyError(error); | ||
run.events.push({ | ||
@@ -373,3 +383,3 @@ name: "error", | ||
run.end_time = Date.now(); | ||
run.error = error.message; | ||
run.error = this.stringifyError(error); | ||
run.events.push({ | ||
@@ -376,0 +386,0 @@ name: "error", |
{ | ||
"name": "@langchain/core", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "Core LangChain.js abstractions and schemas", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1561384
38723