Skip to content

Commit

Permalink
Handle system role via chat/completions
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jun 20, 2024
1 parent 2a51fc2 commit 7d3a9ce
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions r2ai/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ def handle_v1_chat_completions(self, ai, obj, runline2, method):
return True
if "messages" not in obj:
return handle_v1_completions_default(self, ai, obj, runline2, method)
codequery = obj["messages"][0]["content"]
#runline2(ai, "-R")
user = []
system = []
for m in obj["messages"]:
if m["role"] == "system":
system.push(m["content"])
else:
user.push(m["content"])
rolequery = system.join("\n")
codequery = user.join("\n")
WANTCTX = ai.env["http.chatctx"] == "true"
if not WANTCTX:
runline2(ai, "-R")
runline2(ai, "-r " + rolequery)
response = json.loads('''{
"id": "r2ai",
"object": "chat.completion.chunk",
Expand Down

0 comments on commit 7d3a9ce

Please sign in to comment.