Skip to content

Commit fedea6b

Browse files
committed
INTERPRETER_ACTIVE_LINE_DETECTION control and INTERPRETER_TERMINAL_INPUT_PATIENCE control
1 parent 874cb4b commit fedea6b

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

interpreter/core/computer/terminal/languages/jupyter_language.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ def iopub_message_listener():
149149
self.finish_flag = True
150150
return
151151
try:
152+
input_patience = int(
153+
os.environ.get("INTERPRETER_TERMINAL_INPUT_PATIENCE", 15)
154+
)
152155
if (
153-
time.time() - self.last_output_time > 15
154-
and time.time() - self.last_output_message_time > 15
156+
time.time() - self.last_output_time > input_patience
157+
and time.time() - self.last_output_message_time > input_patience
155158
):
156159
self.last_output_message_time = time.time()
157160

@@ -364,7 +367,11 @@ def preprocess_python(code):
364367

365368
# Add print commands that tell us what the active line is
366369
# but don't do this if any line starts with ! or %
367-
if not any(line.strip().startswith(("!", "%")) for line in code.split("\n")):
370+
if (
371+
not any(line.strip().startswith(("!", "%")) for line in code.split("\n"))
372+
and os.environ.get("INTERPRETER_ACTIVE_LINE_DETECTION", "True").lower()
373+
== "true"
374+
):
368375
code = add_active_line_prints(code)
369376

370377
# Wrap in a try except (DISABLED)

interpreter/core/computer/terminal/languages/shell.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def preprocess_shell(code):
4545

4646
# Add commands that tell us what the active line is
4747
# if it's multiline, just skip this. soon we should make it work with multiline
48-
if not has_multiline_commands(code):
48+
if (
49+
not has_multiline_commands(code)
50+
and os.environ.get("INTERPRETER_ACTIVE_LINE_DETECTION", "True").lower()
51+
== "true"
52+
):
4953
code = add_active_line_prints(code)
5054

5155
# Add end command (we'll be listening for this so we know when it ends)

interpreter/core/utils/truncate_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def truncate_output(data, max_output_chars=2800, add_scrollbars=False):
44

55
needs_truncation = False
66

7-
message = f"Output truncated. Showing the last {max_output_chars} characters.\n\n"
7+
message = f"Output truncated. Showing the last {max_output_chars} characters. You should try again and use computer.ai.summarize(output) over the output, or break it down into smaller steps.\n\n"
88

99
# This won't work because truncated code is stored in interpreter.messages :/
1010
# If the full code was stored, we could do this:

0 commit comments

Comments
 (0)