Skip to content

Commit

Permalink
Return null if the input is undefined value. (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
tureki authored Nov 28, 2023
1 parent f6d0614 commit 8684351
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions langchain/src/output_parsers/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// MIT License

export function parsePartialJson(s: string) {
// If the input is undefined, return null to indicate failure.
if (typeof s === "undefined") {
return null;
}

// Attempt to parse the string as-is.
try {
return JSON.parse(s);
Expand Down

0 comments on commit 8684351

Please sign in to comment.