Skip to content

Commit 8863fab

Browse files
committed
Handle judge layer models, handle files
1 parent e9d92c9 commit 8863fab

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

interpreter/core/async_core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ def accumulate(self, chunk):
137137
# We don't do anything with these.
138138
pass
139139

140-
elif "start" in chunk:
140+
elif (
141+
"start" in chunk
142+
or chunk["type"] != self.messages[-1]["type"]
143+
or chunk.get("format") != self.messages[-1].get("format")
144+
):
141145
chunk_copy = (
142146
chunk.copy()
143147
) # So we don't modify the original chunk, which feels wrong.

interpreter/core/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ def _respond_and_store(self):
303303

304304
# Utility function
305305
def is_active_line_chunk(chunk):
306-
return "format" in chunk and chunk["format"] == "active_line"
306+
if "format" in chunk and chunk["format"] == "active_line":
307+
return True
308+
if chunk["type"] == "review":
309+
return True
310+
return False
307311

308312
last_flag_base = None
309313

interpreter/core/llm/run_function_calling_llm.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,30 @@ def run_function_calling_llm(llm, request_params):
4040
accumulated_deltas = {}
4141
language = None
4242
code = ""
43+
function_call_detected = False
4344

4445
for chunk in llm.completions(**request_params):
4546
if "choices" not in chunk or len(chunk["choices"]) == 0:
4647
# This happens sometimes
4748
continue
4849

4950
delta = chunk["choices"][0]["delta"]
50-
5151
# Accumulate deltas
5252
accumulated_deltas = merge_deltas(accumulated_deltas, delta)
5353

5454
if "content" in delta and delta["content"]:
55-
yield {"type": "message", "content": delta["content"]}
55+
if function_call_detected:
56+
# More content after a code block? This is a code review by a judge layer.
57+
yield {"type": "review", "content": delta["content"]}
58+
else:
59+
yield {"type": "message", "content": delta["content"]}
5660

5761
if (
5862
accumulated_deltas.get("function_call")
5963
and "arguments" in accumulated_deltas["function_call"]
6064
and accumulated_deltas["function_call"]["arguments"]
6165
):
66+
function_call_detected = True
6267
if (
6368
"name" in accumulated_deltas["function_call"]
6469
and accumulated_deltas["function_call"]["name"] == "execute"

interpreter/terminal_interface/terminal_interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ def terminal_interface(interpreter, message):
243243
if "content" in chunk:
244244
active_block.code += chunk["content"]
245245

246+
if chunk["type"] == "review" and chunk.get("content"):
247+
# Specialized models can emit a code review.
248+
print(chunk.get("content"), end="", flush=True)
249+
246250
# Execution notice
247251
if chunk["type"] == "confirmation":
248252
if not interpreter.auto_run:

0 commit comments

Comments
 (0)