mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-02 09:26:09 +01:00
fixes
This commit is contained in:
@@ -4,17 +4,14 @@ import signal
|
||||
import threading
|
||||
import queue
|
||||
import time
|
||||
import uuid
|
||||
import platform
|
||||
|
||||
from utils.style import yellow, green, white, red, yellow_bold, white_bold
|
||||
from utils.style import yellow, green, red, yellow_bold, white_bold
|
||||
from database.database import get_saved_command_run, save_command_run
|
||||
from const.function_calls import DEBUG_STEPS_BREAKDOWN
|
||||
from helpers.exceptions.TooDeepRecursionError import TooDeepRecursionError
|
||||
from helpers.exceptions.TokenLimitError import TokenLimitError
|
||||
from prompts.prompts import ask_user
|
||||
from utils.questionary import styled_text
|
||||
from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH
|
||||
from const.code_execution import MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH
|
||||
|
||||
interrupted = False
|
||||
|
||||
@@ -108,6 +105,7 @@ def execute_command(project, command, timeout=None, force=False):
|
||||
answer = ask_user(
|
||||
project,
|
||||
f'Can I execute the command: `' + yellow_bold(command) + f'` with {timeout}ms timeout?',
|
||||
False,
|
||||
hint='If yes, just press ENTER'
|
||||
)
|
||||
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
# main.py
|
||||
from __future__ import print_function, unicode_literals
|
||||
import builtins
|
||||
import json
|
||||
import os
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
from termcolor import colored
|
||||
from helpers.ipc import IPCClient
|
||||
from const.ipc import MESSAGE_TYPE
|
||||
from utils.utils import json_serial
|
||||
from utils.style import red
|
||||
|
||||
from helpers.Project import Project
|
||||
|
||||
@@ -4,8 +4,8 @@ import re
|
||||
import sys
|
||||
import uuid
|
||||
from getpass import getuser
|
||||
from termcolor import colored
|
||||
from database.database import get_app, get_app_by_user_workspace
|
||||
from utils.style import green_bold
|
||||
|
||||
|
||||
def get_arguments():
|
||||
@@ -44,18 +44,18 @@ def get_arguments():
|
||||
arguments['name'] = app.name
|
||||
# Add any other fields from the App model you wish to include
|
||||
|
||||
print(colored('\n------------------ LOADING PROJECT ----------------------', 'green', attrs=['bold']))
|
||||
print(colored(f'{app.name} (app_id={arguments["app_id"]})', 'green', attrs=['bold']))
|
||||
print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold']))
|
||||
print(green_bold('\n------------------ LOADING PROJECT ----------------------'))
|
||||
print(green_bold(f'{app.name} (app_id={arguments["app_id"]})'))
|
||||
print(green_bold('--------------------------------------------------------------\n'))
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
# Handle the error as needed, possibly exiting the script
|
||||
else:
|
||||
arguments['app_id'] = str(uuid.uuid4())
|
||||
print(colored('\n------------------ STARTING NEW PROJECT ----------------------', 'green', attrs=['bold']))
|
||||
print(green_bold('\n------------------ STARTING NEW PROJECT ----------------------'))
|
||||
print("If you wish to continue with this project in future run:")
|
||||
print(colored(f'python {sys.argv[0]} app_id={arguments["app_id"]}', 'green', attrs=['bold']))
|
||||
print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold']))
|
||||
print(green_bold(f'python {sys.argv[0]} app_id={arguments["app_id"]}'))
|
||||
print(green_bold('--------------------------------------------------------------\n'))
|
||||
|
||||
if 'email' not in arguments:
|
||||
arguments['email'] = get_email()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from prompt_toolkit.styles import Style
|
||||
import questionary
|
||||
from utils.style import yellow_bold
|
||||
|
||||
import re
|
||||
from database.database import save_user_input, get_saved_user_input
|
||||
from const.ipc import MESSAGE_TYPE
|
||||
|
||||
custom_style = Style.from_dict({
|
||||
'question': '#FFFFFF bold', # the color and style of the question
|
||||
@@ -14,6 +13,11 @@ custom_style = Style.from_dict({
|
||||
})
|
||||
|
||||
|
||||
def remove_ansi_codes(s: str) -> str:
|
||||
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
||||
return ansi_escape.sub('', s)
|
||||
|
||||
|
||||
def styled_select(*args, **kwargs):
|
||||
kwargs["style"] = custom_style # Set style here
|
||||
return questionary.select(*args, **kwargs).unsafe_ask() # .ask() is included here
|
||||
@@ -34,6 +38,7 @@ def styled_text(project, question, ignore_user_input_count=False):
|
||||
config = {
|
||||
'style': custom_style,
|
||||
}
|
||||
question = remove_ansi_codes(question) # Colorama and questionary are not compatible and styling doesn't work
|
||||
response = questionary.text(question, **config).unsafe_ask() # .ask() is included here
|
||||
else:
|
||||
response = print(question, type='user_input_request')
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from termcolor import colored
|
||||
from colorama import Fore, Style
|
||||
|
||||
def red(text):
|
||||
|
||||
Reference in New Issue
Block a user