From b0e6b85ce56b6b7efdc4b8039e4810b07e38720b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Ho=CC=88nicke?= Date: Wed, 10 May 2023 01:02:12 +0200 Subject: [PATCH] refactor: cleanup --- dev_gpt/options/generate/pm/pm.py | 2 +- test/integration/test_generator.py | 36 ++++++++++++++++++------------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/dev_gpt/options/generate/pm/pm.py b/dev_gpt/options/generate/pm/pm.py index d06a0af..5050f2f 100644 --- a/dev_gpt/options/generate/pm/pm.py +++ b/dev_gpt/options/generate/pm/pm.py @@ -60,7 +60,7 @@ Description of the microservice: context, microservice_description, 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 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', ) # database missing diff --git a/test/integration/test_generator.py b/test/integration/test_generator.py index dceb5e1..084bb24 100644 --- a/test/integration/test_generator.py +++ b/test/integration/test_generator.py @@ -70,7 +70,7 @@ def test_generation_level_2(microservice_dir, mock_input_sequence): ) assert generator.generate() == 0 -@pytest.mark.parametrize('mock_input_sequence', [['y']], indirect=True) +@pytest.mark.parametrize('mock_input_sequence', [['y', 'yfinance.Ticker("MSFT").info']], indirect=True) def test_generation_level_3(microservice_dir, mock_input_sequence): """ Requirements: @@ -95,7 +95,27 @@ Example input: 'AAPL' ) assert generator.generate() == 0 -@pytest.mark.parametrize('mock_input_sequence', [['y', 'https://www.signalogic.com/melp/EngSamples/Orig/ENG_M.wav']], indirect=True) +@pytest.mark.parametrize( + 'mock_input_sequence', [ + [ + 'y', + 'https://www.signalogic.com/melp/EngSamples/Orig/ENG_M.wav', + '''\ +import requests +url = "https://transcribe.whisperapi.com" +headers = {{ +'Authorization': 'Bearer {os.environ['WHISPER_API_KEY']}' +}} +data = {{ + "url": "URL_OF_STORED_AUDIO_FILE" +}} +response = requests.post(url, headers=headers, data=data) +assert response.status_code == 200 +print('This is the text from the audio file:', response.json()['text'])''' + ] + ], + indirect=True +) def test_generation_level_4(microservice_dir, mock_input_sequence): """ Requirements: @@ -110,18 +130,6 @@ def test_generation_level_4(microservice_dir, mock_input_sequence): generator = Generator( 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 = {{ -'Authorization': 'Bearer {os.environ['WHISPER_API_KEY']}' -}} -data = {{ - "url": "URL_OF_STORED_AUDIO_FILE" -}} -response = requests.post(url, headers=headers, data=data) -assert response.status_code == 200 -print('This is the text from the audio file:', response.json()['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. 4. Return the the audio file as base64 encoded binary.