Skip to content

Commit

Permalink
Support translations in decai -x
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Oct 13, 2024
1 parent e4d2f77 commit 94b4059
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion decai/decai.r2.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
let decaiApi = "r2"; // uses /cmd endpoint
let decaiCommands = "pdc";
let decaiLanguage = "C";
let decaiHumanLanguage = "English";
let decaiDebug = false;
let decaiContextFile = "";
let decaiModel = "";
Expand All @@ -87,6 +88,9 @@ You can write your custom decai commands in your ~/.radare2rc file.
case "api":
console.log(decaiApi);
break;
case "hlang":
console.log(decaiHumanLanguage);
break;
case "lang":
console.log(decaiLanguage);
break;
Expand Down Expand Up @@ -134,6 +138,9 @@ You can write your custom decai commands in your ~/.radare2rc file.
case "ctxfile":
decaiContextFile = v;
break;
case "hlang":
decaiHumanLanguage = v;
break;
case "lang":
decaiLanguage = v;
break;
Expand Down Expand Up @@ -462,6 +469,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
console.log("decai -e cmds=" + decaiCommands);
console.log("decai -e cache=" + decaiCache);
console.log("decai -e lang=" + decaiLanguage);
console.log("decai -e hlang=" + decaiHumanLanguage);
console.log("decai -e debug=" + decaiDebug);
console.log("decai -e model=" + decaiModel);
}
Expand All @@ -479,7 +487,7 @@ You can write your custom decai commands in your ~/.radare2rc file.
out = "[BEGIN]" + cmds.split(",").map(r2.cmd).join("\n") + "[END]";
r2.cmd("e scr.color=" + origColor);
r2ai("-R");
out = r2ai("Analyze function calls, comments and strings, ignore registers and memory accesess. Considering the references and involved loops make explain the purpose of this function in one or two short sentences.", out, true);
out = r2ai("Analyze function calls, comments and strings, ignore registers and memory accesess. Considering the references and involved loops make explain the purpose of this function in one or two short sentences. Output must be only the translation of the explanation in " + decaiHumanLanguage, out, true);
break;
case "d": // "-d"
out = decaiDecompile(args, false, decaiCache);
Expand Down

0 comments on commit 94b4059

Please sign in to comment.