🏃 fix: run function

This commit is contained in:
Florian Hönicke
2023-05-12 15:25:38 +02:00
parent b337f74d24
commit a8505031d1
2 changed files with 14 additions and 6 deletions

View File

@@ -63,7 +63,7 @@ Description of the microservice:
condition_question='Does the microservice send requests to an API?', 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.', 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', 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 return microservice_description, test_description

View File

@@ -105,14 +105,18 @@ generated_string = gpt(prompt) # fill-in the prompt (str); the output is a stri
template_generate_function = PromptTemplate.from_template( template_generate_function = PromptTemplate.from_template(
general_guidelines_string + ''' 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'. Write a python function which receives as \
The function must full-fill: '{microservice_description}'. 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}'. It will be tested with the following scenario: '{test_description}'.
For the implementation use the following package(s): '{packages}'. 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 from .apis import GPT_3_5_Turbo
import json
``` ```
Obey the following rules: Obey the following rules:
''' + not_allowed_function_string + ''' ''' + 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. 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. 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 from .microservice import func
import json
``` ```
''' + not_allowed_function_string + ''' ''' + not_allowed_function_string + '''
The test must not open local files. The test must not open local files.
@@ -331,7 +336,10 @@ Example:
**microservice.py** **microservice.py**
```python ```python
print('hello world') import json
def func(json_input: str) -> str:
return json_input['img_base64']
```''' ```'''
) )