#131 if process_name is specified to execute_command() keep the process alive

This commit is contained in:
Nicholas Albion
2023-10-05 20:39:01 +11:00
parent 1bc25c331c
commit a38c35fafa
14 changed files with 228 additions and 91 deletions

View File

@@ -0,0 +1,40 @@
import builtins
from helpers.ipc import IPCClient
from const.ipc import MESSAGE_TYPE
def get_custom_print(args):
built_in_print = builtins.print
def print_to_external_process(*args, **kwargs):
# message = " ".join(map(str, args))
message = args[0]
if 'type' not in kwargs:
kwargs['type'] = 'verbose'
elif kwargs['type'] == MESSAGE_TYPE['local']:
local_print(*args, **kwargs)
return
ipc_client_instance.send({
'type': MESSAGE_TYPE[kwargs['type']],
'content': message,
})
if kwargs['type'] == MESSAGE_TYPE['user_input_request']:
return ipc_client_instance.listen()
def local_print(*args, **kwargs):
message = " ".join(map(str, args))
if 'type' in kwargs:
if kwargs['type'] == MESSAGE_TYPE['info']:
return
del kwargs['type']
built_in_print(message, **kwargs)
ipc_client_instance = None
if '--external-log-process-port' in args:
ipc_client_instance = IPCClient(args['--external-log-process-port'])
return print_to_external_process, ipc_client_instance
else:
return local_print, ipc_client_instance

View File

@@ -3,6 +3,7 @@ import os
import hashlib
import requests
from helpers.cli import terminate_running_processes
from utils.questionary import get_user_feedback
@@ -43,6 +44,7 @@ def get_path_id():
def exit_gpt_pilot(ask_feedback=True):
terminate_running_processes()
path_id = get_path_id()
send_telemetry(path_id)

View File

@@ -262,7 +262,8 @@ def stream_gpt_completion(data, req_type, project):
model = os.getenv('MODEL_NAME', 'gpt-4')
endpoint = os.getenv('ENDPOINT')
logger.info(f'> Request model: {model} ({data["model"]}) messages: {data["messages"]}')
logger.info(f'> Request model: {model} ({data["model"]})\n'
+ '\n'.join([f"{message['role']}: {message['content']}" for message in data['messages']]))
if endpoint == 'AZURE':
# If yes, get the AZURE_ENDPOINT from .ENV file