File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,10 @@ def _respond_and_store(self):
301
301
self .verbose = False
302
302
303
303
# 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
+ """
305
308
if "format" in chunk and chunk ["format" ] == "active_line" :
306
309
return True
307
310
if chunk ["type" ] == "review" :
@@ -358,7 +361,7 @@ def is_active_line_chunk(chunk):
358
361
):
359
362
# If they match, append the chunk's content to the current message's content
360
363
# (Except active_line, which shouldn't be stored)
361
- if not is_active_line_chunk (chunk ):
364
+ if not is_ephemeral (chunk ):
362
365
self .messages [- 1 ]["content" ] += chunk ["content" ]
363
366
else :
364
367
# 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):
374
377
yield {** last_flag_base , "start" : True }
375
378
376
379
# Add the chunk as a new message
377
- if not is_active_line_chunk (chunk ):
380
+ if not is_ephemeral (chunk ):
378
381
self .messages .append (chunk )
379
382
380
383
# Yield the chunk itself
Original file line number Diff line number Diff line change @@ -54,7 +54,23 @@ def run_function_calling_llm(llm, request_params):
54
54
if "content" in delta and delta ["content" ]:
55
55
if function_call_detected :
56
56
# 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
+
58
74
else :
59
75
yield {"type" : "message" , "content" : delta ["content" ]}
60
76
You can’t perform that action at this time.
0 commit comments