Skip to content

Commit 197d4bc

Browse files
authored
Merge pull request #1355 from OpenInterpreter/development
New `review` chunks
2 parents 14ef23a + 5af6f9d commit 197d4bc

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

interpreter/core/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ def _respond_and_store(self):
301301
self.verbose = False
302302

303303
# Utility function
304-
def is_active_line_chunk(chunk):
304+
def is_ephemeral(chunk):
305+
"""
306+
Ephemeral = this chunk doesn't contribute to a message we want to save.
307+
"""
305308
if "format" in chunk and chunk["format"] == "active_line":
306309
return True
307310
if chunk["type"] == "review":
@@ -358,7 +361,7 @@ def is_active_line_chunk(chunk):
358361
):
359362
# If they match, append the chunk's content to the current message's content
360363
# (Except active_line, which shouldn't be stored)
361-
if not is_active_line_chunk(chunk):
364+
if not is_ephemeral(chunk):
362365
self.messages[-1]["content"] += chunk["content"]
363366
else:
364367
# If they don't match, yield a end message for the last message type and a start message for the new one
@@ -374,7 +377,7 @@ def is_active_line_chunk(chunk):
374377
yield {**last_flag_base, "start": True}
375378

376379
# Add the chunk as a new message
377-
if not is_active_line_chunk(chunk):
380+
if not is_ephemeral(chunk):
378381
self.messages.append(chunk)
379382

380383
# Yield the chunk itself

interpreter/core/llm/run_function_calling_llm.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,23 @@ def run_function_calling_llm(llm, request_params):
5454
if "content" in delta and delta["content"]:
5555
if function_call_detected:
5656
# More content after a code block? This is a code review by a judge layer.
57-
yield {"type": "review", "content": delta["content"]}
57+
if delta["content"].strip() == "<SAFE>":
58+
yield {"type": "review", "format": "safe", "content": ""}
59+
elif "<UNSAFE>" in delta["content"]:
60+
content = (
61+
delta["content"]
62+
.replace("<UNSAFE>", "")
63+
.replace("</UNSAFE>", "")
64+
)
65+
yield {"type": "review", "format": "unsafe", "content": content}
66+
else:
67+
content = (
68+
delta["content"]
69+
.replace("<WARNING>", "")
70+
.replace("</WARNING>", "")
71+
)
72+
yield {"type": "review", "format": "warning", "content": content}
73+
5874
else:
5975
yield {"type": "message", "content": delta["content"]}
6076

0 commit comments

Comments
 (0)