Skip to content

Commit

Permalink
Ask the model to fix its JSON document if it generates an invalid one.
Browse files Browse the repository at this point in the history
  • Loading branch information
JusticeRage committed Dec 7, 2022
1 parent c16c482 commit c7b0653
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Finally, with the corresponding interpreter, simply run:
```

⚠️ You will also need to edit the script and add your own API key, which can be found on [this page](https://beta.openai.com/account/api-keys).
Please note that davinci-003 queries are not free (although not very expensive) and you will need to setup a payment method.
Please note that davinci-003 queries are not free (although not very expensive) and you will need to set up a payment method.

## Usage

Expand Down
4 changes: 3 additions & 1 deletion gepetto.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def rename_callback(address, view, response):
try:
names = json.loads(j.group(0))
except json.decoder.JSONDecodeError:
print(f"The data returned by the model cannot be parsed. It is dumped below for manual recovery:\n{response}")
print(f"The data returned by the model cannot be parsed. Asking the model to fix it...")
query_model_async("Please fix the following JSON document:\n" + j.group(0),
functools.partial(rename_callback, address=idaapi.get_screen_ea(), view=view))
return

# The rename function needs the start address of the function
Expand Down

0 comments on commit c7b0653

Please sign in to comment.