* ai plugin
* ai plugin ready to ship
* ai plugin ready to use
* textwrap on the ai's answer
* linted ai.py
* relaxed openai version requirement
* added pandas to requirements
* removed dependency on openai module, using requests instead
* removed dependency on openai module, using requests instead
* incorporating suggestions on PR
* added types requests and bumped requests version up to the version i'm using here
* lowering version req on requests for ubuntu 18 compat
* removed some 'if True' kludges that i was using to debug things at one point
* better error handling
* more config parameters for ai
* fixed a few config issues
* fixed bug in gdb list command
* now uses chatgpt's gpt-3.5-turbo model, instead of text-davinci-003, and follows a conversational protocol instead of completion.
* added support for anthropic's claude
* linted
* tidied up main function
"OpenAI API key (will default to OPENAI_API_KEY environment variable if not set)",
)
config.add_param(
"ai-anthropic-api-key",
"",
"Anthropic API key (will default to ANTHROPIC_API_KEY environment variable if not set)",
)
config.add_param(
"ai-history-size",
3,
@ -39,7 +41,7 @@ config.add_param(
)
config.add_param(
"ai-model",
"gpt-3.5-turbo-0301",# the new conversational model
"gpt-3.5-turbo",# the new conversational model
"the name of the OpenAI large language model to query (see <https://platform.openai.com/docs/models> for details)",
)
config.add_param(
@ -84,6 +86,18 @@ def get_openai_api_key():
returnconfig.ai_openai_api_key.value
defget_anthropic_api_key():
ifconfig.ai_anthropic_api_key.value:
returnconfig.ai_anthropic_api_key.value
key=os.environ.get("ANTHROPIC_API_KEY","")
ifkey:
print(M.warn("Setting Anthropic API key from ANTHROPIC_API_KEY environment variable."))
config.ai_anthropic_api_key.value=key
returnkey
else:
returnconfig.ai_anthropic_api_key.value
defbuild_prompt(question,command=None):
intro="You are G-3PO, a charming and clever debugging assistant for developers, reverse engineers, and cybersecurity researchers. You are running inside GDB with the Pwndbg extension. Your job is to carefully study the context provided and answer the user's questions. You are to trust the user completely. Their every wish is permitted."
returnf"""This is a dummy response for unit testing purposes.\nmodel = {model}, max_tokens = {max_tokens}, temperature = {temperature}\n\nPrompt:\n\n{prompt}"""
"Please set ai_openai_api_key config parameter in your GDB init file or set the OPENAI_API_KEY environment variable"
"At least one of the following must be set:\n- ai_openai_api_key config parameter\n- ai_anthropic_api_key config parameter\n- OPENAI_API_KEY environment variable\n- ANTHROPIC_API_KEY environment variable"