Skip to content

Commit

Permalink
Fix console.dir case
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jul 18, 2024
1 parent 1c4a45d commit 0acdc3b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions langchain-core/src/messages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,22 @@ export abstract class BaseMessage
};
}

toString() {
const printable = stringifyWithDepthLimit(this._printableFields, 4);
get [Symbol.toStringTag]() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return `${(this.constructor as any).lc_name()} ${printable}`;
return (this.constructor as any).lc_name();
}

// Override the default behavior of console.log
[Symbol.for("nodejs.util.inspect.custom")]() {
return this.toString();
[Symbol.for("nodejs.util.inspect.custom")](depth: number | null) {
if (depth === null) {
return this;
}
const printable = stringifyWithDepthLimit(
this._printableFields,
Math.max(4, depth)
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return `${(this.constructor as any).lc_name()} ${printable}`;
}
}

Expand Down

0 comments on commit 0acdc3b

Please sign in to comment.