From ebb57979820fba87b91b23a5f45791a8ae83f44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Mon, 1 May 2023 22:31:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA3=EF=B8=8F=E2=83=A3=20test:=20level?= =?UTF-8?q?=203=20refinement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/gpt.py | 4 ++-- src/options/generate/templates_system.py | 10 ++++++---- src/options/generate/templates_user.py | 6 ++++-- test/test_generator.py | 10 ++++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/apis/gpt.py b/src/apis/gpt.py index 16a53af..66512de 100644 --- a/src/apis/gpt.py +++ b/src/apis/gpt.py @@ -11,7 +11,7 @@ from langchain.chat_models import ChatOpenAI from openai.error import RateLimitError from langchain.schema import HumanMessage, SystemMessage, BaseMessage, AIMessage from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler -from requests.exceptions import ConnectionError +from requests.exceptions import ConnectionError, ChunkedEncodingError from urllib3.exceptions import InvalidChunkLength from src.constants import PRICING_GPT4_PROMPT, PRICING_GPT4_GENERATION, PRICING_GPT3_5_TURBO_PROMPT, \ @@ -132,7 +132,7 @@ class _GPTConversation: try: response = self._chat(self.messages) break - except (ConnectionError, InvalidChunkLength) as e: + except (ConnectionError, InvalidChunkLength, ChunkedEncodingError) as e: print('There was a connection error. Retrying...') if i == 9: raise e diff --git a/src/options/generate/templates_system.py b/src/options/generate/templates_system.py index 8583154..70a98d1 100644 --- a/src/options/generate/templates_system.py +++ b/src/options/generate/templates_system.py @@ -48,15 +48,16 @@ Your response must exactly match the following block code format (double asteris ``` b) -Otherwise you respond with the summarized description. -The summarized description must contain all the information mentioned by the client. +Otherwise you respond with the detailed description. +The detailed description must contain all the information mentioned by the client. Your response must exactly match the following block code format (double asterisks for the file name and triple backticks for the file block): **final.json** ```json {{ "description": "", - "implementation_details": "", + "code_samples": "", + "documentation_info": "", "credentials: "" }} ``` @@ -87,7 +88,8 @@ database access: n/a ```json {{ "description": "The user inserts a png and gets an svg as response.", - "implementation_details": "n/a", + "code_samples": "n/a", + "documentation_info": "n/a", "credentials: "n/a" }} ``` diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 88cfcac..873ab81 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -383,12 +383,14 @@ Either ask for clarification like this: }} ``` -Or write the summarized microservice description and additional implementation details like this: +Or write the detailed microservice description all mentioned code samples, documentation info and credentials like this: **final.json** ```json {{ "description": "", - "implementation_details": "", + "example_input_file": "", + "code_samples": "", + "documentation_info": "", "credentials: "" }} ``` diff --git a/test/test_generator.py b/test/test_generator.py index 50bc50c..251509b 100644 --- a/test/test_generator.py +++ b/test/test_generator.py @@ -85,8 +85,9 @@ def test_generation_level_3(tmpdir): """ os.environ['VERBOSE'] = 'true' generator = Generator( - f'''Given an audio file (1min) of speech like https://www.signalogic.com/melp/EngSamples/Orig/ENG_M.wav, -get convert it to text using the following api: + f'''Given an audio file (1min wav) of speech, +1. convert it to text using the Whisper API. +Here is the documentation on how to use the API: import requests url = "https://transcribe.whisperapi.com" headers = {{ @@ -97,8 +98,9 @@ data = {{ }} response = requests.post(url, headers=headers, files=file, data=data) print(response.text) -Summarize the text (50 words). -Create an audio file of the summarized text. +2. Summarize the text (~50 words) while still maintaining the key facts. +3. Create an audio file of the summarized text using a tts library. +Example input file: https://www.signalogic.com/melp/EngSamples/Orig/ENG_M.wav ''', str(tmpdir) + 'microservice', 'gpt-3.5-turbo'