mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-23 18:35:08 +01:00
Show stderr in real time
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
MAX_COMMAND_DEBUG_TRIES = 3
|
||||
MIN_COMMAND_RUN_TIME = 2000
|
||||
MAX_COMMAND_RUN_TIME = 30000
|
||||
MAX_COMMAND_OUTPUT_LENGTH = 2000
|
||||
|
||||
@@ -43,6 +43,7 @@ class AgentConvo:
|
||||
if self.agent.project.skip_until_dev_step and str(development_step.id) == self.agent.project.skip_until_dev_step:
|
||||
self.agent.project.skip_steps = False
|
||||
delete_all_subsequent_steps(self.agent.project)
|
||||
|
||||
if 'delete_unrelated_steps' in self.agent.project.args and self.agent.project.args['delete_unrelated_steps']:
|
||||
self.agent.project.delete_all_steps_except_current_branch()
|
||||
else:
|
||||
|
||||
@@ -141,7 +141,7 @@ class Developer(Agent):
|
||||
iteration_convo.remove_last_x_messages(2)
|
||||
self.execute_task(iteration_convo, task_steps, continue_development=False)
|
||||
|
||||
|
||||
|
||||
def set_up_environment(self):
|
||||
self.project.current_step = 'environment_setup'
|
||||
self.convo_os_specific_tech = AgentConvo(self)
|
||||
|
||||
@@ -11,7 +11,7 @@ from database.database import get_command_run_from_hash_id, save_command_run
|
||||
from const.function_calls import DEBUG_STEPS_BREAKDOWN
|
||||
|
||||
from utils.questionary import styled_text
|
||||
from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME
|
||||
from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH
|
||||
|
||||
interrupted = False
|
||||
|
||||
@@ -71,6 +71,7 @@ def execute_command(project, command, timeout=None, force=False):
|
||||
pid_container = [None]
|
||||
process = run_command(command, project.root_path, q, q_stderr, pid_container)
|
||||
output = ''
|
||||
stderr_output = ''
|
||||
start_time = time.time()
|
||||
interrupted = False
|
||||
|
||||
@@ -105,6 +106,17 @@ def execute_command(project, command, timeout=None, force=False):
|
||||
if line:
|
||||
output += line
|
||||
print(colored('CLI OUTPUT:', 'green') + line, end='')
|
||||
|
||||
# Read stderr
|
||||
try:
|
||||
stderr_line = q_stderr.get_nowait()
|
||||
except queue.Empty:
|
||||
stderr_line = None
|
||||
|
||||
if stderr_line:
|
||||
stderr_output += stderr_line
|
||||
print(colored('CLI ERROR:', 'red') + stderr_line, end='') # Print with different color for distinction
|
||||
|
||||
except (KeyboardInterrupt, TimeoutError) as e:
|
||||
interrupted = True
|
||||
if isinstance(e, KeyboardInterrupt):
|
||||
@@ -114,15 +126,15 @@ def execute_command(project, command, timeout=None, force=False):
|
||||
|
||||
os.killpg(pid_container[0], signal.SIGKILL) # Kill the process group
|
||||
|
||||
stderr_output = ''
|
||||
while not q_stderr.empty():
|
||||
stderr_output += q_stderr.get_nowait()
|
||||
# stderr_output = ''
|
||||
# while not q_stderr.empty():
|
||||
# stderr_output += q_stderr.get_nowait()
|
||||
|
||||
if return_value is None:
|
||||
return_value = ''
|
||||
if stderr_output != '':
|
||||
return_value = 'stderr:\n```\n' + stderr_output[-2000:] + '\n```\n'
|
||||
return_value += 'stdout:\n```\n' + output[-2000:] + '\n```'
|
||||
return_value = 'stderr:\n```\n' + stderr_output[-MAX_COMMAND_OUTPUT_LENGTH:] + '\n```\n'
|
||||
return_value += 'stdout:\n```\n' + output[-MAX_COMMAND_OUTPUT_LENGTH:] + '\n```'
|
||||
|
||||
command_run = save_command_run(project, command, return_value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user