Spaces:
Sleeping
Sleeping
Julian Bilcke
commited on
Commit
·
2531bbf
1
Parent(s):
345a592
handle a new hallucination case
Browse files- src/app/main.tsx +1 -1
- src/app/queries/getStory.ts +0 -1
- src/lib/dirtyLLMResponseCleaner.ts +6 -0
src/app/main.tsx
CHANGED
|
@@ -105,7 +105,7 @@ export default function Main() {
|
|
| 105 |
setTimeout(() => {
|
| 106 |
setGeneratingStory(false)
|
| 107 |
setWaitABitMore(false)
|
| 108 |
-
},
|
| 109 |
}
|
| 110 |
})
|
| 111 |
}, [prompt, preset?.label]) // important: we need to react to preset changes too
|
|
|
|
| 105 |
setTimeout(() => {
|
| 106 |
setGeneratingStory(false)
|
| 107 |
setWaitABitMore(false)
|
| 108 |
+
}, 10000)
|
| 109 |
}
|
| 110 |
})
|
| 111 |
}, [prompt, preset?.label]) // important: we need to react to preset changes too
|
src/app/queries/getStory.ts
CHANGED
|
@@ -82,7 +82,6 @@ export const getStory = async ({
|
|
| 82 |
|
| 83 |
captions = dirtyLLMJsonParser(strategy2)
|
| 84 |
} catch (err2) {
|
| 85 |
-
|
| 86 |
// in case of failure here, it might be because the LLM hallucinated a completely different response,
|
| 87 |
// such as markdown. There is no real solution.. but we can try a fallback:
|
| 88 |
|
|
|
|
| 82 |
|
| 83 |
captions = dirtyLLMJsonParser(strategy2)
|
| 84 |
} catch (err2) {
|
|
|
|
| 85 |
// in case of failure here, it might be because the LLM hallucinated a completely different response,
|
| 86 |
// such as markdown. There is no real solution.. but we can try a fallback:
|
| 87 |
|
src/lib/dirtyLLMResponseCleaner.ts
CHANGED
|
@@ -2,6 +2,12 @@ export function dirtyLLMResponseCleaner(input: string) {
|
|
| 2 |
return (
|
| 3 |
`${input || ""}`
|
| 4 |
// a summary of all the weird hallucinations I saw it make..
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
.replaceAll("}}", "}")
|
| 6 |
.replaceAll("]]", "]")
|
| 7 |
.replaceAll(",,", ",")
|
|
|
|
| 2 |
return (
|
| 3 |
`${input || ""}`
|
| 4 |
// a summary of all the weird hallucinations I saw it make..
|
| 5 |
+
.replaceAll(`"]`, `"}]`)
|
| 6 |
+
.replaceAll(`" ]`, `"}]`)
|
| 7 |
+
.replaceAll(`" ]`, `"}]`)
|
| 8 |
+
.replaceAll(`"\n]`, `"}]`)
|
| 9 |
+
.replaceAll(`"\n ]`, `"}]`)
|
| 10 |
+
.replaceAll(`"\n ]`, `"}]`)
|
| 11 |
.replaceAll("}}", "}")
|
| 12 |
.replaceAll("]]", "]")
|
| 13 |
.replaceAll(",,", ",")
|