This commit is contained in:
Paul Gauthier 2024-08-16 07:03:42 -07:00
parent ae9ad0989e
commit dde7470f4d

View file

@ -182,9 +182,6 @@ Below is an example of a `SyntaxError` created by gpt-4o-2024-05-13 using the
JSON code wrapping strategy. JSON code wrapping strategy.
It appears that the model got confused about escaping and quoting while trying It appears that the model got confused about escaping and quoting while trying
to format the JSON response. to format the JSON response.
The source code contains a single-quoted string which also
contains a single-quote character.
The word `There'll` should have been escaped as `There\'ll`.
```python ```python
Traceback (most recent call last): Traceback (most recent call last):
@ -195,6 +192,21 @@ Traceback (most recent call last):
SyntaxError: unterminated string literal (detected at line 9) SyntaxError: unterminated string literal (detected at line 9)
``` ```
The problematic line of code contains a single-quoted string which also
contains a single-quote character.
It should have been output as the following chunk of JSON, with
a double slash in `There\\'ll`.
That is needed to JSON-escape the `\` so that it survives
JSON-decoding to
produce `There\'ll` in the resulting code.
That would correctly escape the single-quote inside the single-quoted string.
```
...lyrics.append(f'There\\'ll be {i - 1} green bottles hanging on the wall.')\n...
```
{% include code-in-json-syntax.js %} {% include code-in-json-syntax.js %}
> Figure 2: Number of `SyntaxError` and `IndentationError` errors found in model generated code, > Figure 2: Number of `SyntaxError` and `IndentationError` errors found in model generated code,