Skip to content

Commit

Permalink
Fix unescaped backslashes in JSON produced by GPT
Browse files Browse the repository at this point in the history
  • Loading branch information
DieterHolvoet committed Jun 9, 2023
1 parent 95fa4b0 commit c8fd6b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Solutions/OpenAi/OpenAiSolutionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c8fd6b8

Please sign in to comment.