Skip to content

Commit

Permalink
Fixing a typo and a bug in the error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
JusticeRage committed Dec 4, 2022
1 parent 0285a1f commit d4936f9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions gepetto.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ class GepettoHandler(idaapi.action_handler_t):
def __init__(self):
idaapi.action_handler_t.__init__(self)

# Say hello when invoked.
def activate(self, ctx):
decompiler_output = ida_hexrays.decompile(idaapi.get_screen_ea())
v = ida_hexrays.get_widget_vdui(ctx.widget)
query_chatgpt_async("Can you explain what the following C function does?\n" + str(decompiler_output) +
"\nSuggest better name for the function and its arguments.",
"\nSuggest better names for the function and its arguments.",
functools.partial(comment_callback, address=idaapi.get_screen_ea(), view=v))
return 1

Expand Down Expand Up @@ -117,7 +116,7 @@ def query_chatgpt(query, cb):
presence_penalty=1
)
cb(response=response.choices[0].text)
except openai.error as e:
except openai.OpenAIError as e:
raise print(f"ChatGPT could not complete the request: {str(e)}")


Expand Down

0 comments on commit d4936f9

Please sign in to comment.