mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
Merge branch 'main' into debugging_ipc
# Conflicts: # README.md # pilot/helpers/agents/CodeMonkey.py # pilot/helpers/agents/Developer.py # pilot/prompts/system_messages/architect.prompt # pilot/utils/arguments.py # pilot/utils/llm_connection.py # pilot/utils/utils.py
This commit is contained in:
@@ -52,7 +52,6 @@ def get_arguments():
|
||||
# Handle the error as needed, possibly exiting the script
|
||||
else:
|
||||
arguments['app_id'] = str(uuid.uuid4())
|
||||
# TODO: This intro is also presented by Project.py. This version is not presented in the VS Code extension
|
||||
print(colored('\n------------------ STARTING NEW PROJECT ----------------------', 'green', attrs=['bold']))
|
||||
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']))
|
||||
|
||||
@@ -95,6 +95,7 @@ def create_gpt_chat_completion(messages: List[dict], req_type, min_tokens=MIN_TO
|
||||
if key in gpt_data:
|
||||
del gpt_data[key]
|
||||
|
||||
# Advise the LLM of the JSON response schema we are expecting
|
||||
add_function_calls_to_request(gpt_data, function_calls)
|
||||
|
||||
try:
|
||||
@@ -140,8 +141,11 @@ def get_tokens_in_messages_from_openai_error(error_message):
|
||||
|
||||
def retry_on_exception(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
# spinner = None
|
||||
|
||||
while True:
|
||||
try:
|
||||
# spinner_stop(spinner)
|
||||
return func(*args, **kwargs)
|
||||
except Exception as e:
|
||||
# Convert exception to string
|
||||
@@ -154,16 +158,19 @@ def retry_on_exception(func):
|
||||
args[0]['function_buffer'] = e.doc
|
||||
continue
|
||||
if "context_length_exceeded" in err_str:
|
||||
# spinner_stop(spinner)
|
||||
raise TokenLimitError(get_tokens_in_messages_from_openai_error(err_str), MAX_GPT_MODEL_TOKENS)
|
||||
if "rate_limit_exceeded" in err_str:
|
||||
# Extracting the duration from the error string
|
||||
match = re.search(r"Please try again in (\d+)ms.", err_str)
|
||||
if match:
|
||||
# spinner = spinner_start(colored("Rate limited. Waiting...", 'yellow'))
|
||||
wait_duration = int(match.group(1)) / 1000
|
||||
time.sleep(wait_duration)
|
||||
continue
|
||||
|
||||
print(red(f'There was a problem with request to openai API:'))
|
||||
# spinner_stop(spinner)
|
||||
print(err_str)
|
||||
|
||||
user_message = questionary.text(
|
||||
@@ -363,7 +370,7 @@ def assert_json_schema(response: str, functions: list[FunctionType]) -> True:
|
||||
return True
|
||||
|
||||
|
||||
def postprocessing(gpt_response, req_type):
|
||||
def postprocessing(gpt_response: str, req_type) -> str:
|
||||
return gpt_response
|
||||
|
||||
|
||||
|
||||
@@ -9,4 +9,5 @@ def spinner_start(text="Processing..."):
|
||||
|
||||
|
||||
def spinner_stop(spinner):
|
||||
spinner.stop()
|
||||
if spinner is not None:
|
||||
spinner.stop()
|
||||
|
||||
@@ -85,6 +85,10 @@ def get_prompt_components():
|
||||
|
||||
|
||||
def get_sys_message(role):
|
||||
"""
|
||||
:param role: 'product_owner', 'architect', 'dev_ops', 'tech_lead', 'full_stack_developer', 'code_monkey'
|
||||
:return: { "role": "system", "content": "You are a {role}... You do..." }
|
||||
"""
|
||||
content = get_prompt(f'system_messages/{role}.prompt')
|
||||
|
||||
return {
|
||||
@@ -137,7 +141,7 @@ def should_execute_step(arg_step, current_step):
|
||||
def step_already_finished(args, step):
|
||||
args.update(step['app_data'])
|
||||
|
||||
message = f"{capitalize_first_word_with_underscores(step['step'])} already done for this app_id: {args['app_id']}. Moving to next step..."
|
||||
message = f"✅ {capitalize_first_word_with_underscores(step['step'])}"
|
||||
print(green(message))
|
||||
logger.info(message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user