diff --git a/README.md b/README.md index 418bcb3..d496888 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,20 @@ Your imagination is the limit! Discord Chat -[![Watch the video](res/thumbnail.png)]() + +[![Watch the video](res/thumbnail.png)](https://user-images.githubusercontent.com/11627845/231530421-272a66aa-4260-4e17-ab7a-ba66adca754c.mp4)

This project streamlines the creation and deployment of microservices. Simply describe your task using natural language, and the system will automatically build and deploy your microservice. To ensure the microservice accurately aligns with your intended task a test scenario is required. +Join our Discord logo to get in touch with the team and other users. + + ## Quickstart ### Requirements +- OpenAI key with access to GPT-4 - Create an account at [cloud.jina.ai](https://cloud.jina.ai) where your microservice will be deployed ### Installation @@ -114,7 +119,7 @@ gptdeploy create --description "Given a 3d object, return vertex count and face ### Table extraction ```bash ---description "Given a URL, extract all tables as csv" --test "http://www.ins.tn/statistiques/90" +gptdeploy create --description "Given a URL, extract all tables as csv" --test "http://www.ins.tn/statistiques/90" ``` Table Extraction diff --git a/res/discord.png b/res/discord.png new file mode 100644 index 0000000..c636650 Binary files /dev/null and b/res/discord.png differ diff --git a/src/executor_factory.py b/src/executor_factory.py index 830cc5d..c8923c6 100644 --- a/src/executor_factory.py +++ b/src/executor_factory.py @@ -7,7 +7,7 @@ from src.constants import FILE_AND_TAG_PAIRS from src.jina_cloud import push_executor, process_error_message from src.prompt_tasks import general_guidelines, executor_file_task, chain_of_thought_creation, test_executor_file_task, \ chain_of_thought_optimization, requirements_file_task, docker_file_task, not_allowed -from src.utils.io import recreate_folder, persist_file +from src.utils.io import persist_file from src.utils.string_tools import print_colored @@ -66,10 +66,11 @@ class ExecutorFactory: output_path, executor_name, package, + num_approach, is_chain_of_thought=False, ): - EXECUTOR_FOLDER_v1 = self.get_executor_path(output_path, package, 1) - recreate_folder(EXECUTOR_FOLDER_v1) + EXECUTOR_FOLDER_v1 = self.get_executor_path(output_path, executor_name, package, num_approach, 1) + os.makedirs(EXECUTOR_FOLDER_v1) print_colored('', '############# Executor #############', 'red') user_query = ( @@ -167,22 +168,22 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul playground_content = self.extract_content_from_result(playground_content_raw, 'app.py') persist_file(playground_content, os.path.join(executor_path, 'app.py')) - def get_executor_path(self, output_path, package, version): + def get_executor_path(self, output_path, executor_name, package, num_approach, version): package_path = '_'.join(package) - return os.path.join(output_path, package_path, f'v{version}') + return os.path.join(output_path, executor_name, f'{num_approach}_{package_path}', f'v{version}') - def debug_executor(self, output_path, package, description, test): + def debug_executor(self, output_path, executor_name, num_approach, packages, description, test): MAX_DEBUGGING_ITERATIONS = 10 error_before = '' for i in range(1, MAX_DEBUGGING_ITERATIONS): print('Debugging iteration', i) print('Trying to build the microservice. Might take a while...') - previous_executor_path = self.get_executor_path(output_path, package, i) - next_executor_path = self.get_executor_path(output_path, package, i + 1) + previous_executor_path = self.get_executor_path(output_path, executor_name, packages, num_approach, i) + next_executor_path = self.get_executor_path(output_path, executor_name, packages, num_approach, i + 1) log_hubble = push_executor(previous_executor_path) error = process_error_message(log_hubble) if error: - recreate_folder(next_executor_path) + os.makedirs(next_executor_path) file_name_to_content = self.get_all_executor_files_with_content(previous_executor_path) all_files_string = self.files_to_string(file_name_to_content) user_query = ( @@ -223,7 +224,7 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul break if i == MAX_DEBUGGING_ITERATIONS - 1: raise self.MaxDebugTimeReachedException('Could not debug the executor.') - return self.get_executor_path(output_path, package, i) + return self.get_executor_path(output_path, executor_name, packages, num_approach, i) class MaxDebugTimeReachedException(BaseException): pass @@ -285,11 +286,10 @@ package2,package3,... generated_name = self.generate_executor_name(description) executor_name = f'{generated_name}{random.randint(0, 1000_000)}' packages_list = self.get_possible_packages(description, num_approaches) - recreate_folder(output_path) - for packages in packages_list: + for num_approach, packages in enumerate(packages_list): try: - self.create_executor(description, test, output_path, executor_name, packages) - executor_path = self.debug_executor(output_path, packages, description, test) + self.create_executor(description, test, output_path, executor_name, packages, num_approach) + executor_path = self.debug_executor(output_path, executor_name, num_approach, packages, description, test) host = jina_cloud.deploy_flow(executor_name, executor_path) self.create_playground(executor_name, executor_path, host) except self.MaxDebugTimeReachedException: diff --git a/src/utils/io.py b/src/utils/io.py index 9e53475..a9104f5 100644 --- a/src/utils/io.py +++ b/src/utils/io.py @@ -6,13 +6,9 @@ from typing import Generator import sys from contextlib import contextmanager -def recreate_folder(folder_path): - if os.path.exists(folder_path) and os.path.isdir(folder_path): - shutil.rmtree(folder_path) - os.makedirs(folder_path) -def persist_file(file_content, file_name): - with open(f'{file_name}', 'w') as f: +def persist_file(file_content, file_path): + with open(file_path, 'w') as f: f.write(file_content)