Skip to content

Commit

Permalink
Merge pull request #1953 from Agenta-AI/fix/human-evaluation-syntax-e…
Browse files Browse the repository at this point in the history
…rror

Fix: human evaluation tests syntax error
  • Loading branch information
mmabrouk authored Aug 11, 2024
2 parents dec77a7 + 877a63c commit 379dfb1
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 379dfb1

Please sign in to comment.