Skip to content

Commit

Permalink
fix: fixed human evaluation tests syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
ashrafchowdury committed Jul 30, 2024
1 parent 75b9b0c commit 877a63c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions agenta-web/src/lib/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,15 @@ export const removeKeys = (obj: GenericObject, keys: string[]) => {

export const safeParse = (str: string, fallback: any = "") => {
try {
return JSON.parse(str)
if (!str) return fallback

if (typeof str !== "string") {
return JSON.parse(str)
} else {
return str
}
} catch (error) {
console.log("error parsing JSON:", error)
console.log("fallbacking to:", fallback)
return fallback
}
}
Expand Down

0 comments on commit 877a63c

Please sign in to comment.