@@ -230,6 +230,11 @@ def _generate_retrieve_user_reply(
230
230
sender : Optional [Agent ] = None ,
231
231
config : Optional [Any ] = None ,
232
232
) -> Tuple [bool , Union [str , Dict , None ]]:
233
+ """In this function, we will update the context and reset the conversation based on different conditions.
234
+ We'll update the context and reset the conversation if no_update_context is False and either of the following:
235
+ (1) the last message contains "UPDATE CONTEXT",
236
+ (2) the last message doesn't contain "UPDATE CONTEXT" and the customized_answer_prefix is not in the message.
237
+ """
233
238
if config is None :
234
239
config = self
235
240
if messages is None :
@@ -335,21 +340,6 @@ def run_code(self, code, **kwargs):
335
340
if self ._ipython is None or lang != "python" :
336
341
return super ().run_code (code , ** kwargs )
337
342
else :
338
- # # capture may not work as expected
339
- # result = self._ipython.run_cell("%%capture --no-display cap\n" + code)
340
- # log = self._ipython.ev("cap.stdout")
341
- # log += self._ipython.ev("cap.stderr")
342
- # if result.result is not None:
343
- # log += str(result.result)
344
- # exitcode = 0 if result.success else 1
345
- # if result.error_before_exec is not None:
346
- # log += f"\n{result.error_before_exec}"
347
- # exitcode = 1
348
- # if result.error_in_exec is not None:
349
- # log += f"\n{result.error_in_exec}"
350
- # exitcode = 1
351
- # return exitcode, log, None
352
-
353
343
result = self ._ipython .run_cell (code )
354
344
log = str (result .result )
355
345
exitcode = 0 if result .success else 1
0 commit comments