Skip to content

Commit

Permalink
Improve decai prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Oct 21, 2024
1 parent dde67b6 commit d09a4f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decai/decai.r2.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
let decaiModel = "";
let lastOutput = "";
let decaiCache = false;
let decprompt = "Respond with code and DO NOT explain or use markdown. Keep it simple and remove unnecessary statements, Rewrite the goto statements into higher level constructs using 'string:' and call arguments from comments, use better names for variables and remove unnecessary or confusing logic";
let decprompt = "Do not explain, respond using ONLY code. Simplify and and make it more readable. Use better variable names, keep it simple and avoid unnecessary logic, rewrite 'goto' into higher level constructs, Use comments like 'string:' to resolve function call arguments";

function decaiEval(arg) {
const [k, v] = arg.split("=");
Expand Down Expand Up @@ -227,7 +227,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
// const hfModel = "meta-llama/Llama-3.1-8B-Instruct";
// const hfModel = "meta-llama/Llama-3.2-1B-Instruct";
// const hfModel = "Qwen/Qwen2.5-72B-Instruct";
const query = hideprompt? msg: decprompt + ", Explain this pseudocode in " + decaiLanguage + "\n" + msg;
const query = hideprompt? msg: decprompt + ", Transform this pseudocode into " + decaiLanguage + "\n" + msg;
const payload = JSON.stringify({
inputs: query,
parameters: {
Expand Down Expand Up @@ -267,7 +267,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
return "Cannot read ~/.r2ai.openai-key";
}
const openaiModel = (decaiModel.length > 0)? decaiModel: "gpt-4";
const query = hideprompt? msg: decprompt + ", Explain this pseudocode in " + decaiLanguage + "\n" + msg;
const query = hideprompt? msg: decprompt + ", Transform this pseudocode into " + decaiLanguage + "\n" + msg;
const payload = JSON.stringify({
model: openaiModel,
max_tokens: 5128,
Expand All @@ -293,7 +293,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
return "error invalid response";
}
function r2aiOpenAPI(msg, hideprompt) {
const query = hideprompt? msg: decprompt + ", Explain this pseudocode in " + decaiLanguage + "\n" + msg;
const query = hideprompt? msg: decprompt + ", Transform this pseudocode into " + decaiLanguage + "\n" + msg;
const payload = JSON.stringify({ "prompt": query });
const curlcmd = `curl -s ${decaiHost}:${decaiPort}/completion
-H "Content-Type: application/json"
Expand Down

0 comments on commit d09a4f4

Please sign in to comment.