-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for the kobaldcpp endpoint
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.Dd May 14, 2024 | ||
.Dt R2AI 1 | ||
.Sh NAME | ||
.Nm r2ai | ||
.Nd radare2 artificial intelligence integration | ||
.Sh SYNOPSIS | ||
.Nm r2ai | ||
.Op [-h] | ||
.Op [...] | ||
.Sh DESCRIPTION | ||
Integrate multiple language models and inference engines with radare2 for reverse engineering and chatting purposes. | ||
.Bl -tag -width Fl | ||
.It Fl m Ar model | ||
Select a different model name | ||
.Sh USAGE | ||
.Pp | ||
The plugin can be used from the shell, via r2pipe or from radare2. | ||
.Pp | ||
You need the rlang-python plugin installed in your system to use the r2ai plugin from radare2, which adds the `r2ai` command in the r2 shell. | ||
.Pp | ||
It is also possible to use r2ai without rlang, via r2pipe, so you can run `#!pipe python main.py` instead. | ||
.Pp | ||
.Sh INSTALLATION | ||
.Pp | ||
$ r2ai -i r2ai | ||
.Sh FILES | ||
.Pp | ||
~/r2ai.rc - run this script every time | ||
~/r2ai.model - symlink to the directory containing all downloaded models | ||
~/r2ai.history - file storing all messages written | ||
~/r2ai.openai-key - write the key from your openai thing | ||
~/r2ai.mastodon-key - write the key from your Mastodon thing | ||
~/r2ai.plugins - directory containing r2ai plugin scripts to be executed with .. | ||
.Sh SEE ALSO | ||
.Pp | ||
.Xr radare2(1) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
import json | ||
import requests | ||
|
||
def chat(message): | ||
API_ENDPOINT='http://localhost:5001/v1/completions' | ||
data = { | ||
"max_length": 1024, | ||
"prompt": message, | ||
"quiet": True, | ||
"n": 1, | ||
"echo": False, | ||
"stop": ["\nUser:"], | ||
"rep_pen": 1.1, | ||
"rep_pen_range": 256, | ||
"rep_pen_slope": 1, | ||
"temperature": 0.3, | ||
"tfs": 1, | ||
"top_a": 0, | ||
"top_k": 100, | ||
"top_p": 0.9, | ||
"typical": 1 | ||
} | ||
r = requests.post(url=API_ENDPOINT, data=json.dumps(data)) | ||
j = json.loads(r.text) | ||
i = j["choices"][0]["text"] | ||
return i | ||
|
||
#m = slurp("/Users/pancake/prg/r2ai/doc/data/quotes.txt") | ||
#AI="AI" | ||
#US="User" | ||
#CTX="Context" | ||
#fullmsg = f"Context:\n```{m}```\nYour name is r2ai, an assistant for radare2. User will ask about actions and you must respond with the radare2 command associated or the answer to the question. Be precise and concise when answering" | ||
#while True: | ||
# message = input() | ||
# qmsg = f"{CTX}:\n```{fullmsg}\n```\n{US}: {message}\n" | ||
# r = query_completions(qmsg) | ||
# r = r.replace(f"{AI}:", "").strip() | ||
# r = r.replace(f"{US}:", "").strip() | ||
# r = r.replace("```", "").strip() | ||
# print(r) | ||
# fullmsg = f"{fullmsg}\n{US}: {message}\n{AI}: {r}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters