feat: support for gpt

This commit is contained in:
Florian Hönicke
2023-04-20 01:58:51 +02:00
parent 7fa5052874
commit 16bbe8bdce
6 changed files with 31 additions and 50 deletions

View File

@@ -6,7 +6,7 @@ from src.apis import gpt
from src.apis.jina_cloud import process_error_message, push_executor
from src.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS, \
PROBLEMATIC_PACKAGES, EXECUTOR_FILE_NAME, EXECUTOR_FILE_TAG, TEST_EXECUTOR_FILE_NAME, TEST_EXECUTOR_FILE_TAG, \
REQUIREMENTS_FILE_NAME, REQUIREMENTS_FILE_TAG, DOCKER_FILE_NAME, DOCKER_FILE_TAG, GPT_3_5_TURBO_API_FILE_NAME
REQUIREMENTS_FILE_NAME, REQUIREMENTS_FILE_TAG, DOCKER_FILE_NAME, DOCKER_FILE_TAG
from src.options.generate.templates_user import template_generate_microservice_name, template_generate_possible_packages, \
template_solve_code_issue, \
template_solve_dependency_issue, template_is_dependency_issue, template_generate_playground, \
@@ -82,13 +82,10 @@ metas:
MICROSERVICE_FOLDER_v1 = get_microservice_path(path, microservice_name, packages, num_approach, 1)
os.makedirs(MICROSERVICE_FOLDER_v1)
gpt_3_5_turbo_api_content = self.write_gpt_api_file(MICROSERVICE_FOLDER_v1)
microservice_content = self.generate_and_persist_file(
'Microservice',
template_generate_executor,
MICROSERVICE_FOLDER_v1,
code_files_wrapped=self.files_to_string({'gpt_3_5_turbo_api.py': gpt_3_5_turbo_api_content}),
microservice_name=microservice_name,
microservice_description=self.task_description,
test_description=self.test_description,
@@ -102,7 +99,7 @@ metas:
'Test Microservice',
template_generate_test,
MICROSERVICE_FOLDER_v1,
code_files_wrapped=self.files_to_string({'microservice.py': microservice_content, 'gpt_3_5_turbo_api.py': gpt_3_5_turbo_api_content,}),
code_files_wrapped=self.files_to_string({'microservice.py': microservice_content}),
microservice_name=microservice_name,
microservice_description=self.task_description,
test_description=self.test_description,
@@ -118,7 +115,6 @@ metas:
code_files_wrapped=self.files_to_string({
'microservice.py': microservice_content,
'test_microservice.py': test_microservice_content,
'gpt_3_5_turbo_api.py': gpt_3_5_turbo_api_content,
}),
file_name_purpose=REQUIREMENTS_FILE_NAME,
file_name=REQUIREMENTS_FILE_NAME,
@@ -133,7 +129,6 @@ metas:
'microservice.py': microservice_content,
'test_microservice.py': test_microservice_content,
'requirements.txt': requirements_content,
'gpt_3_5_turbo_api.py': gpt_3_5_turbo_api_content,
}),
file_name_purpose=DOCKER_FILE_NAME,
file_name=DOCKER_FILE_NAME,
@@ -278,10 +273,3 @@ gptdeploy deploy --path {microservice_path}
error_summary = conversation.chat(template_summarize_error.format(error=error))
return error_summary
def write_gpt_api_file(self, MICROSERVICE_FOLDER_v1):
cur_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(cur_dir, GPT_3_5_TURBO_API_FILE_NAME), 'r', encoding='utf-8') as file:
GPT_3_5_Turbo_API_content = file.read()
with open(os.path.join(MICROSERVICE_FOLDER_v1, GPT_3_5_TURBO_API_FILE_NAME), 'w', encoding='utf-8') as file:
file.write(GPT_3_5_Turbo_API_content)
return GPT_3_5_Turbo_API_content