Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jul 17, 2024
1 parent c4eefc0 commit 1c4a45d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions langchain-core/src/messages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,25 @@ export function mergeContent(
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function stringifyWithDepthLimit(obj: any, depthLimit: number): string {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function helper(obj: any, currentDepth: number): any {
if (typeof obj !== "object" || obj === null) {
if (typeof obj !== "object" || obj === null || obj === undefined) {
return obj;
}
if (currentDepth >= depthLimit) {
if (Array.isArray(obj)) {
return "[Array]";
}
return "[Object]";
}

if (Array.isArray(obj)) {
return obj.map((item) => helper(item, currentDepth + 1));
}

const result: any = {};
const result: Record<string, unknown> = {};
for (const key of Object.keys(obj)) {
result[key] = helper(obj[key], currentDepth + 1);
}
Expand Down Expand Up @@ -267,7 +272,8 @@ export abstract class BaseMessage
}

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

Expand Down

0 comments on commit 1c4a45d

Please sign in to comment.