From da69941ca966d4650a518fd61d35d72d25a6e432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 11 May 2023 01:16:45 +0200 Subject: [PATCH 01/10] =?UTF-8?q?=F0=9F=92=B8=20refactor:=20costs=20on=20v?= =?UTF-8?q?erbose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/apis/gpt.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dev_gpt/apis/gpt.py b/dev_gpt/apis/gpt.py index 2f07a02..949fb4a 100644 --- a/dev_gpt/apis/gpt.py +++ b/dev_gpt/apis/gpt.py @@ -88,11 +88,12 @@ class GPTSession: self.chars_prompt_so_far += chars_prompt self.chars_generation_so_far += chars_generation if print_costs: - print('\n') - money_prompt = self._calculate_money_spent(self.chars_prompt_so_far, self.pricing_prompt) - money_generation = self._calculate_money_spent(self.chars_generation_so_far, self.pricing_generation) - print('Total money spent so far on openai.com:', f'${money_prompt + money_generation:.3f}') - print('\n') + if os.environ['VERBOSE'].lower() == 'true': + print('\n') + money_prompt = self._calculate_money_spent(self.chars_prompt_so_far, self.pricing_prompt) + money_generation = self._calculate_money_spent(self.chars_generation_so_far, self.pricing_generation) + print('Total money spent so far on openai.com:', f'${money_prompt + money_generation:.3f}') + print('\n') @staticmethod def _calculate_money_spent(num_chars, price): From 21b7efe4ae7f35f979951c560907be8bc7df7c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 11 May 2023 10:30:13 +0200 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=8F=83=20fix:=20run=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/cli.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/dev_gpt/cli.py b/dev_gpt/cli.py index 4c0b29a..08d2ada 100644 --- a/dev_gpt/cli.py +++ b/dev_gpt/cli.py @@ -35,9 +35,6 @@ def path_param(func): def wrapper(*args, **kwargs): path = os.path.expanduser(kwargs['path']) path = os.path.abspath(path) - if os.path.exists(path) and os.listdir(path): - click.echo(f"Error: The path {path} you provided via --path is not empty. Please choose a directory that does not exist or is empty.") - exit(1) kwargs['path'] = path return func(*args, **kwargs) return wrapper From 6d8ba8ac575c54780103bce002152b79e97eeabf Mon Sep 17 00:00:00 2001 From: Jina Dev Bot Date: Thu, 11 May 2023 09:09:59 +0000 Subject: [PATCH 03/10] chore(version): the next version will be 0.18.39 build(florian-hoenicke): sldjfalsdf --- dev_gpt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_gpt/__init__.py b/dev_gpt/__init__.py index ffe4dfc..f20cdf8 100644 --- a/dev_gpt/__init__.py +++ b/dev_gpt/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.18.38' +__version__ = '0.18.39' from dev_gpt.cli import main \ No newline at end of file From 9326cba1bdd26536bef809a583af0b362f070063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 11 May 2023 12:15:05 +0200 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=8F=83=20fix:=20run=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index ee06ba1..97b99b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ jina==3.15.1.dev14 click streamlit==1.9.0 +altair==4.2.2 openai>=0.27.5 psutil jcloud From 840a19aadfe2fc7cbd5e1ee63944679237d73965 Mon Sep 17 00:00:00 2001 From: Jina Dev Bot Date: Thu, 11 May 2023 10:17:58 +0000 Subject: [PATCH 05/10] chore(version): the next version will be 0.18.40 build(florian-hoenicke): streamlit requirements need to be fixed --- dev_gpt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_gpt/__init__.py b/dev_gpt/__init__.py index f20cdf8..1afc918 100644 --- a/dev_gpt/__init__.py +++ b/dev_gpt/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.18.39' +__version__ = '0.18.40' from dev_gpt.cli import main \ No newline at end of file From b337f74d24d38b4b8e12e1af87fa99ccccda4528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Thu, 11 May 2023 21:53:21 +0200 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=8F=83=20fix:=20run=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/apis/gpt.py | 2 +- .../options/generate/static_files/microservice/jina_wrapper.py | 2 +- dev_gpt/options/generate/templates_user.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev_gpt/apis/gpt.py b/dev_gpt/apis/gpt.py index 949fb4a..44d329f 100644 --- a/dev_gpt/apis/gpt.py +++ b/dev_gpt/apis/gpt.py @@ -77,7 +77,7 @@ class GPTSession: }] ) break - except RateLimitError: + except (RateLimitError, openai.error.APIError): sleep(1) continue return True diff --git a/dev_gpt/options/generate/static_files/microservice/jina_wrapper.py b/dev_gpt/options/generate/static_files/microservice/jina_wrapper.py index bfc4553..5cd7191 100644 --- a/dev_gpt/options/generate/static_files/microservice/jina_wrapper.py +++ b/dev_gpt/options/generate/static_files/microservice/jina_wrapper.py @@ -11,5 +11,5 @@ class DevGPTExecutor(Executor): @jina_requests() def endpoint(self, docs: DocumentArray, **kwargs) -> DocumentArray: for d in docs: - d.text = json.dumps(func(json.loads(d.text))) + d.text = func(d.text) return docs diff --git a/dev_gpt/options/generate/templates_user.py b/dev_gpt/options/generate/templates_user.py index 8eea63f..a7a373e 100644 --- a/dev_gpt/options/generate/templates_user.py +++ b/dev_gpt/options/generate/templates_user.py @@ -105,7 +105,7 @@ generated_string = gpt(prompt) # fill-in the prompt (str); the output is a stri template_generate_function = PromptTemplate.from_template( general_guidelines_string + ''' -Write a python function which receives as input a dictionary and outputs a dictionary. The function is called 'func'. +Write a python function which receives as input json string (that can be parsed with the python function json.loads) and outputs a json string (that can be parsed with the python function json.loads). The function is called 'func'. The function must full-fill: '{microservice_description}'. It will be tested with the following scenario: '{test_description}'. For the implementation use the following package(s): '{packages}'. From 9dd7be868294a3532710ce0ad20d94714b82a29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6nicke?= Date: Fri, 12 May 2023 14:12:30 +0200 Subject: [PATCH 07/10] docs: update discord channel --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35e2dbe..99c1292 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Your imagination is the limit! Downloads - + Discord Chat From a8505031d14f2d159b56a81b763c650e4d935718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Fri, 12 May 2023 15:25:38 +0200 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=8F=83=20fix:=20run=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/options/generate/pm/pm.py | 2 +- dev_gpt/options/generate/templates_user.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dev_gpt/options/generate/pm/pm.py b/dev_gpt/options/generate/pm/pm.py index 105eb7a..7f3dfa5 100644 --- a/dev_gpt/options/generate/pm/pm.py +++ b/dev_gpt/options/generate/pm/pm.py @@ -63,7 +63,7 @@ Description of the microservice: condition_question='Does the microservice send requests to an API?', question_gen='Generate a question that asks for the endpoint and an example of a request and response when interacting with the external API.', extension_name='Example of API usage', - post_transformation_fn=translation(from_format='api instruction', to_format='python code snippet') + post_transformation_fn=translation(from_format='api instruction', to_format='python code snippet raw without formatting') ) return microservice_description, test_description diff --git a/dev_gpt/options/generate/templates_user.py b/dev_gpt/options/generate/templates_user.py index a7a373e..efc9c38 100644 --- a/dev_gpt/options/generate/templates_user.py +++ b/dev_gpt/options/generate/templates_user.py @@ -105,14 +105,18 @@ generated_string = gpt(prompt) # fill-in the prompt (str); the output is a stri template_generate_function = PromptTemplate.from_template( general_guidelines_string + ''' -Write a python function which receives as input json string (that can be parsed with the python function json.loads) and outputs a json string (that can be parsed with the python function json.loads). The function is called 'func'. -The function must full-fill: '{microservice_description}'. +Write a python function which receives as \ +input json string (that can be parsed with the python function json.loads) and \ +outputs a json string (that can be parsed with the python function json.loads). \ +The function is called 'func'. +The function must fulfill the following description: '{microservice_description}'. It will be tested with the following scenario: '{test_description}'. For the implementation use the following package(s): '{packages}'. -The code must start with the following import: +The code must start with the following imports: ``` from .apis import GPT_3_5_Turbo +import json ``` Obey the following rules: ''' + not_allowed_function_string + ''' @@ -134,9 +138,10 @@ template_generate_test = PromptTemplate.from_template( Write a single pytest case that tests the following scenario: '{test_description}'. In case the test scenario is not precise enough, test a general case without any assumptions. Start the test with an extensive comment about the test case. If gpt_3_5_turbo is used in the executor, then the test must not check the exact output of the executor as it is not deterministic. -The test must start with the following import: +The test must start with the following imports: ``` from .microservice import func +import json ``` ''' + not_allowed_function_string + ''' The test must not open local files. @@ -331,7 +336,10 @@ Example: **microservice.py** ```python -print('hello world') +import json + +def func(json_input: str) -> str: + return json_input['img_base64'] ```''' ) From 203ceea068f166e1b49f856701714d9d6ecee9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Fri, 12 May 2023 15:52:24 +0200 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=8F=83=20fix:=20run=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev_gpt/options/generate/templates_user.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev_gpt/options/generate/templates_user.py b/dev_gpt/options/generate/templates_user.py index efc9c38..fff03ee 100644 --- a/dev_gpt/options/generate/templates_user.py +++ b/dev_gpt/options/generate/templates_user.py @@ -153,9 +153,9 @@ The test must not set any environment variables which require a key. template_generate_requirements = PromptTemplate.from_template( - general_guidelines_string + ''' + general_guidelines_string + f''' -{code_files_wrapped} +{{code_files_wrapped}} Write the content of the requirements.txt file like this: **requirements.txt** @@ -165,9 +165,11 @@ Write the content of the requirements.txt file like this: Add any more packages that are needed to run the code. You must not add gpt_3_5_turbo to the requirements.txt file. -All versions are fixed using ~=, ==, <, >, <=, >=. The package versions must not have conflicts. Output only the requirements.txt file. -''' + '\n' + template_code_wrapping_string -) +All versions are fixed using ~=, ==, <, >, <=, >=. The package versions must not have conflicts. + +{template_code_wrapping_string} +Note: you must only output the requirements.txt file - no other file. +''') template_generate_apt_get_install = PromptTemplate.from_template( From 53ae1d6f4c1c0037c4aa671cd2f100521952a319 Mon Sep 17 00:00:00 2001 From: Jina Dev Bot Date: Fri, 12 May 2023 14:24:53 +0000 Subject: [PATCH 10/10] chore(version): the next version will be 0.18.41 build(florian-hoenicke): fix the run function --- dev_gpt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_gpt/__init__.py b/dev_gpt/__init__.py index 1afc918..e878c41 100644 --- a/dev_gpt/__init__.py +++ b/dev_gpt/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.18.40' +__version__ = '0.18.41' from dev_gpt.cli import main \ No newline at end of file