From c8fd6b8dc089328ef3c44811885b79e0eabfd07d Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Fri, 9 Jun 2023 15:29:35 +0200 Subject: [PATCH] Fix unescaped backslashes in JSON produced by GPT --- src/Solutions/OpenAi/OpenAiSolutionResponse.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Solutions/OpenAi/OpenAiSolutionResponse.php b/src/Solutions/OpenAi/OpenAiSolutionResponse.php index cefc2682..27799978 100644 --- a/src/Solutions/OpenAi/OpenAiSolutionResponse.php +++ b/src/Solutions/OpenAi/OpenAiSolutionResponse.php @@ -23,6 +23,9 @@ public function links(): array $textLinks = explode(PHP_EOL, $textLinks); $textLinks = array_map(function ($textLink) { + $textLink = str_replace('\\', '\\\\', $textLink); + $textLink = str_replace('\\\\\\', '\\\\', $textLink); + return json_decode($textLink, true); }, $textLinks);