mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-25 01:14:24 +01:00
♻ refactor: rename package
This commit is contained in:
@@ -36,9 +36,9 @@ class Generator:
|
||||
self.gpt_session = gpt.GPTSession(task_description, test_description, model=model)
|
||||
self.microservice_specification = TaskSpecification(task=task_description, test=test_description)
|
||||
|
||||
def extract_content_from_result(self, plain_text, file_name, match_single_block=False):
|
||||
|
||||
pattern = fr"^\*\*{file_name}\*\*\n```(?:\w+\n)?([\s\S]*?)\n```" # the \n at the end makes sure that ``` within the generated code is not matched
|
||||
def extract_content_from_result(self, plain_text, file_name, match_single_block=False, can_contain_code_block=True):
|
||||
optional_line_break = '\n' if can_contain_code_block else '' # the \n at the end makes sure that ``` within the generated code is not matched because it is not right before a line break
|
||||
pattern = fr"^\*\*{file_name}\*\*\n```(?:\w+\n)?([\s\S]*?){optional_line_break}```"
|
||||
match = re.search(pattern, plain_text, re.MULTILINE)
|
||||
if match:
|
||||
return match.group(1).strip()
|
||||
@@ -361,7 +361,6 @@ Test scenario:
|
||||
''')
|
||||
|
||||
def refine_task(self, pm):
|
||||
|
||||
task_description = self.microservice_specification.task
|
||||
if not task_description:
|
||||
task_description = self.get_user_input(pm, 'What should your microservice do?')
|
||||
@@ -374,8 +373,8 @@ Test scenario:
|
||||
print('thinking...')
|
||||
agent_response_raw = conversation.chat(task_description, role='user')
|
||||
|
||||
question = self.extract_content_from_result(agent_response_raw, 'prompt.txt')
|
||||
task_final = self.extract_content_from_result(agent_response_raw, 'task-final.txt')
|
||||
question = self.extract_content_from_result(agent_response_raw, 'prompt.txt', can_contain_code_block=False)
|
||||
task_final = self.extract_content_from_result(agent_response_raw, 'task-final.txt', can_contain_code_block=False)
|
||||
if task_final:
|
||||
self.microservice_specification.task = task_final
|
||||
break
|
||||
@@ -392,13 +391,14 @@ Test scenario:
|
||||
user_input = self.microservice_specification.task
|
||||
while True:
|
||||
conversation = self.gpt_session.get_conversation(messages, print_stream=os.environ['VERBOSE'].lower() == 'true', print_costs=False)
|
||||
print('thinking...')
|
||||
agent_response_raw = conversation.chat(f'''**client-response.txt**
|
||||
```
|
||||
{user_input}
|
||||
```
|
||||
''', role='user')
|
||||
question = self.extract_content_from_result(agent_response_raw, 'prompt.txt')
|
||||
test_final = self.extract_content_from_result(agent_response_raw, 'test-final.txt')
|
||||
question = self.extract_content_from_result(agent_response_raw, 'prompt.txt', can_contain_code_block=False)
|
||||
test_final = self.extract_content_from_result(agent_response_raw, 'test-final.txt', can_contain_code_block=False)
|
||||
if test_final:
|
||||
self.microservice_specification.test = test_final
|
||||
break
|
||||
|
||||
@@ -144,12 +144,11 @@ Your response must exactly match the following block code format:
|
||||
**task-final.txt**
|
||||
```text
|
||||
<task here>
|
||||
``` <-- this is in a new line
|
||||
```
|
||||
|
||||
The character sequence ``` must always be at the beginning of the line.
|
||||
You must not add information that was not provided by the client.
|
||||
|
||||
|
||||
Example for the description "given a city, get the weather report for the next 5 days":
|
||||
input: ✅
|
||||
output: ✅
|
||||
@@ -161,7 +160,6 @@ database access: n/a
|
||||
Please provide the url of the weather api and a valid api key. Or let our engineers try to find a free api.
|
||||
```
|
||||
|
||||
|
||||
Example for the description "convert png to svg":
|
||||
input: ✅
|
||||
output: ✅
|
||||
@@ -173,7 +171,6 @@ database access: n/a
|
||||
The user inserts a png and gets an svg as response.
|
||||
```
|
||||
|
||||
|
||||
Example for the description "parser":
|
||||
input: ❌
|
||||
output: ❌
|
||||
@@ -191,8 +188,8 @@ system_test_iteration = f'''
|
||||
The client gives you a description of the microservice.
|
||||
Your task is to describe verbally a unit test for that microservice.
|
||||
There are two cases:
|
||||
a) The unit test requires a file as input.
|
||||
In this case you must ask the client to provide the file as URL.
|
||||
a) The unit test requires an example file as input.
|
||||
In this case you must ask the client to provide the example file as URL.
|
||||
Your response must exactly match the following block code format:
|
||||
|
||||
**prompt.txt**
|
||||
@@ -233,7 +230,7 @@ The user inserts a png and gets an svg as response.
|
||||
PM:
|
||||
**prompt.txt**
|
||||
```text
|
||||
Please provide a png file as url.
|
||||
Please provide a png example file as url.
|
||||
```
|
||||
Client:
|
||||
**client-response.txt**
|
||||
@@ -245,4 +242,18 @@ PM:
|
||||
```text
|
||||
The test takes the png https://aquasecurity.github.io/kube-bench/v0.6.5/images/kube-bench-logo-only.png as input and asserts the output is an svg.
|
||||
```
|
||||
|
||||
Example 3:
|
||||
Client:
|
||||
**client-response.txt**
|
||||
```
|
||||
The microservice takes nothing as input and returns the current time.
|
||||
```
|
||||
PM:
|
||||
**test-final.txt**
|
||||
```text
|
||||
The test takes nothing as input and asserts that the output is a string.
|
||||
```
|
||||
|
||||
|
||||
'''
|
||||
Reference in New Issue
Block a user