refactor: summarize error message without line number

This commit is contained in:
Florian Hönicke
2023-06-06 11:42:51 +02:00
parent 048db486c7
commit 63734f939e
2 changed files with 13 additions and 3 deletions

View File

@@ -72,6 +72,7 @@ SEARCH_PACKAGES = [
] ]
TOOL_TO_ALIASES = { TOOL_TO_ALIASES = {
'gpt_3_5_turbo': ['gpt-3', 'GPT-3'] 'gpt_3_5_turbo': ['gpt-3', 'GPT-3'],
'google_custom_search': ['Google Custom Search API']
} }

View File

@@ -525,17 +525,18 @@ pytest
def get_possible_packages(self): def get_possible_packages(self):
print_colored('', '\n\n############# What packages to use? #############', 'blue') print_colored('', '\n\n############# What packages to use? #############', 'blue')
packages_json = ask_gpt(template_generate_possible_packages, self_healing_json_parser, description=self.microservice_specification.task) packages_json = ask_gpt(template_generate_possible_packages, self_healing_json_parser, description=self.microservice_specification.task)
packages_list = self.process_packages_json_string(packages_json) packages_list = self.process_packages_json_string(packages_json, self.microservice_specification.task)
return packages_list return packages_list
@staticmethod @staticmethod
def process_packages_json_string(packages_json): def process_packages_json_string(packages_json, task_description):
packages_list = [[pkg.strip().lower().replace('-', '_') for pkg in packages] for packages in packages_json] packages_list = [[pkg.strip().lower().replace('-', '_') for pkg in packages] for packages in packages_json]
packages_list = [[Generator.replace_with_tool_if_possible(pkg) for pkg in packages] for packages in packages_list = [[Generator.replace_with_tool_if_possible(pkg) for pkg in packages] for packages in
packages_list] packages_list]
packages_list = Generator.filter_packages_list(packages_list) packages_list = Generator.filter_packages_list(packages_list)
packages_list = Generator.remove_duplicates_from_packages_list(packages_list) packages_list = Generator.remove_duplicates_from_packages_list(packages_list)
packages_list = Generator.add_tools_if_missing(packages_list, task_description)
packages_list = packages_list[:NUM_IMPLEMENTATION_STRATEGIES] packages_list = packages_list[:NUM_IMPLEMENTATION_STRATEGIES]
return packages_list return packages_list
@@ -608,6 +609,14 @@ You can now run or deploy your microservice:
def remove_duplicates_from_packages_list(packages_list): def remove_duplicates_from_packages_list(packages_list):
return [list(set(packages)) for packages in packages_list] return [list(set(packages)) for packages in packages_list]
@classmethod
def add_tools_if_missing(cls, packages_list, task_description):
for packages in packages_list:
for tool in ['gpt_3_5_turbo', 'google_custom_search']:
if tool not in packages and tool in task_description:
packages.append(tool)
return packages_list
# def create_prototype_implementation(self): # def create_prototype_implementation(self):
# microservice_py_lines = ['''\ # microservice_py_lines = ['''\
# Class {microservice_name}:'''] # Class {microservice_name}:''']