mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-21 15:44:19 +01:00
fix: feedback
This commit is contained in:
@@ -6,7 +6,7 @@ from src.apis import gpt
|
|||||||
from src.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS
|
from src.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS
|
||||||
from src.apis.jina_cloud import process_error_message, push_executor
|
from src.apis.jina_cloud import process_error_message, push_executor
|
||||||
from src.options.generate.prompt_tasks import general_guidelines, chain_of_thought_creation, executor_file_task, \
|
from src.options.generate.prompt_tasks import general_guidelines, chain_of_thought_creation, executor_file_task, \
|
||||||
not_allowed, chain_of_thought_optimization, test_executor_file_task, requirements_file_task, docker_file_task
|
not_allowed_executor, chain_of_thought_optimization, test_executor_file_task, requirements_file_task, docker_file_task
|
||||||
from src.utils.io import persist_file, get_all_microservice_files_with_content, get_microservice_path
|
from src.utils.io import persist_file, get_all_microservice_files_with_content, get_microservice_path
|
||||||
from src.utils.string_tools import print_colored
|
from src.utils.string_tools import print_colored
|
||||||
|
|
||||||
@@ -76,10 +76,10 @@ class Generator:
|
|||||||
microservice_content_raw = conversation.query(user_query)
|
microservice_content_raw = conversation.query(user_query)
|
||||||
if is_chain_of_thought:
|
if is_chain_of_thought:
|
||||||
microservice_content_raw = conversation.query(
|
microservice_content_raw = conversation.query(
|
||||||
f"General rules: " + not_allowed() + chain_of_thought_optimization('python', 'microservice.py'))
|
f"General rules: " + not_allowed_executor() + chain_of_thought_optimization('python', 'microservice.py'))
|
||||||
microservicer_content = self.extract_content_from_result(executor_content_raw, 'microservice.py', match_single_block=True)
|
microservice_content = self.extract_content_from_result(microservice_content_raw, 'microservice.py', match_single_block=True)
|
||||||
if microservice_content == '':
|
if microservice_content == '':
|
||||||
microservice_content_raw = conversation.query('Please add the executor code.')
|
microservice_content_raw = conversation.query('You must add the executor code.')
|
||||||
microservice_content = self.extract_content_from_result(
|
microservice_content = self.extract_content_from_result(
|
||||||
microservice_content_raw, 'microservice.py', match_single_block=True
|
microservice_content_raw, 'microservice.py', match_single_block=True
|
||||||
)
|
)
|
||||||
@@ -95,7 +95,7 @@ class Generator:
|
|||||||
test_microservice_content_raw = conversation.query(user_query)
|
test_microservice_content_raw = conversation.query(user_query)
|
||||||
if is_chain_of_thought:
|
if is_chain_of_thought:
|
||||||
test_microservice_content_raw = conversation.query(
|
test_microservice_content_raw = conversation.query(
|
||||||
f"General rules: " + not_allowed() +
|
f"General rules: " + not_allowed_executor() +
|
||||||
chain_of_thought_optimization('python', 'test_microservice.py')
|
chain_of_thought_optimization('python', 'test_microservice.py')
|
||||||
+ "Don't add any additional tests. "
|
+ "Don't add any additional tests. "
|
||||||
)
|
)
|
||||||
@@ -133,7 +133,7 @@ class Generator:
|
|||||||
dockerfile_content_raw = conversation.query(user_query)
|
dockerfile_content_raw = conversation.query(user_query)
|
||||||
if is_chain_of_thought:
|
if is_chain_of_thought:
|
||||||
dockerfile_content_raw = conversation.query(
|
dockerfile_content_raw = conversation.query(
|
||||||
f"General rules: " + not_allowed() + chain_of_thought_optimization('dockerfile', 'Dockerfile'))
|
f"General rules: " + not_allowed_executor() + chain_of_thought_optimization('dockerfile', 'Dockerfile'))
|
||||||
dockerfile_content = self.extract_content_from_result(dockerfile_content_raw, 'Dockerfile', match_single_block=True)
|
dockerfile_content = self.extract_content_from_result(dockerfile_content_raw, 'Dockerfile', match_single_block=True)
|
||||||
persist_file(dockerfile_content, os.path.join(MICROSERVICE_FOLDER_v1, 'Dockerfile'))
|
persist_file(dockerfile_content, os.path.join(MICROSERVICE_FOLDER_v1, 'Dockerfile'))
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ response = client.post('/', inputs=DocumentArray([d])) # always use '/'
|
|||||||
print(response[0].text) # can also be blob in case of image/audio..., this should be visualized in the streamlit app
|
print(response[0].text) # can also be blob in case of image/audio..., this should be visualized in the streamlit app
|
||||||
```
|
```
|
||||||
Note that the response will always be in response[0].text
|
Note that the response will always be in response[0].text
|
||||||
Please provide the complete file with the exact same syntax to wrap the code.
|
You must provide the complete file with the exact same syntax to wrap the code.
|
||||||
The playground (app.py) must read the host from sys.argv because it will be started with a custom host: streamlit run app.py -- --host grpc://...
|
The playground (app.py) must read the host from sys.argv because it will be started with a custom host: streamlit run app.py -- --host grpc://...
|
||||||
The playground (app.py) must not let the user configure the host on the ui.
|
The playground (app.py) must not let the user configure the host on the ui.
|
||||||
'''
|
'''
|
||||||
@@ -198,19 +198,19 @@ The playground (app.py) must not let the user configure the host on the ui.
|
|||||||
f"identify the type of error by examining the stack trace. Once you have identified the "
|
f"identify the type of error by examining the stack trace. Once you have identified the "
|
||||||
f"error, you should suggest how to solve it. Your response should include the files that "
|
f"error, you should suggest how to solve it. Your response should include the files that "
|
||||||
f"need to be changed, but not files that don't need to be changed. For files that need to "
|
f"need to be changed, but not files that don't need to be changed. For files that need to "
|
||||||
f"be changed, please provide the complete file with the exact same syntax to wrap the code.\n\n"
|
f"be changed, you must provide the complete file with the exact same syntax to wrap the code.\n\n"
|
||||||
f"You are given the following files:\n\n{all_files_string}"
|
f"You are given the following files:\n\n{all_files_string}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
all_files_string = self.files_to_string(file_name_to_content)
|
all_files_string = self.files_to_string(file_name_to_content)
|
||||||
user_query = (
|
user_query = (
|
||||||
f"General rules: " + not_allowed()
|
f"General rules: " + not_allowed_executor()
|
||||||
+ f'Here is the description of the task the executor must solve:\n{description}'
|
+ f'Here is the description of the task the executor must solve:\n{description}'
|
||||||
+ f'\n\nHere is the test scenario the executor must pass:\n{test}'
|
+ f'\n\nHere is the test scenario the executor must pass:\n{test}'
|
||||||
+ f'Here are all the files I use:\n{all_files_string}'
|
+ f'Here are all the files I use:\n{all_files_string}'
|
||||||
+ f'\n\nThis error happens during the docker build process:\n{error}\n\n'
|
+ ((f'This is an error that I already fixed before:\n{error_before}\n\n') if error_before else '')
|
||||||
+ ((f'This is an error that is already fixed before:\n{error_before}\n\n') if error_before else '')
|
+ f'\n\nThis is the error I encounter currently during the docker build process:\n{error}\n\n'
|
||||||
+ 'Look at exactly at the stack trace. First, think about what kind of error is this? '
|
+ 'Look at the stack trace of the current error. First, think about what kind of error is this? '
|
||||||
'Then think about possible reasons which might have caused it. Then suggest how to '
|
'Then think about possible reasons which might have caused it. Then suggest how to '
|
||||||
'solve it. Output the files that need change. '
|
'solve it. Output the files that need change. '
|
||||||
"Don't output files that don't need change. If you output a file, then write the "
|
"Don't output files that don't need change. If you output a file, then write the "
|
||||||
@@ -288,7 +288,7 @@ For each subtask:
|
|||||||
For each package:
|
For each package:
|
||||||
Write down some non-obvious thoughts about the challenges you might face for the task and give multiple approaches on how you handle them.
|
Write down some non-obvious thoughts about the challenges you might face for the task and give multiple approaches on how you handle them.
|
||||||
For example, there might be some packages you must not use because they do not obay the rules:
|
For example, there might be some packages you must not use because they do not obay the rules:
|
||||||
{not_allowed()}
|
{not_allowed_executor()}
|
||||||
Discuss the pros and cons for all of these packages.
|
Discuss the pros and cons for all of these packages.
|
||||||
Create a list of package subsets that you could use to solve the task.
|
Create a list of package subsets that you could use to solve the task.
|
||||||
The list is sorted in a way that the most promising subset of packages is at the top.
|
The list is sorted in a way that the most promising subset of packages is at the top.
|
||||||
|
|||||||
@@ -71,4 +71,4 @@ print(response[0].text)
|
|||||||
```'''
|
```'''
|
||||||
|
|
||||||
|
|
||||||
system_base_definition = f'''You are a principal engineer working at Jina - an open source company.'''
|
system_base_definition = f'''You are a principal engineer working at Jina - an open source company. You accurately satisfy all of the user's requirements.'''
|
||||||
@@ -17,10 +17,10 @@ def general_guidelines():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _task(task, tag_name, file_name, function_name=None):
|
def _task(task, tag_name, file_name, purpose=None):
|
||||||
into_string = file_name
|
into_string = file_name
|
||||||
if function_name:
|
if purpose:
|
||||||
into_string += f"/{function_name}"
|
into_string += f"/{purpose}"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
task + f"The code will go into {into_string}. Make sure to wrap the code into ``` marks even if you only "
|
task + f"The code will go into {into_string}. Make sure to wrap the code into ``` marks even if you only "
|
||||||
@@ -28,7 +28,7 @@ def _task(task, tag_name, file_name, function_name=None):
|
|||||||
f"**{file_name}**\n"
|
f"**{file_name}**\n"
|
||||||
f"```{tag_name}\n"
|
f"```{tag_name}\n"
|
||||||
f"...code...\n"
|
f"...code...\n"
|
||||||
f"```\nPlease provide the complete file with the exact same syntax to wrap the code."
|
f"```\nYou must provide the complete file with the exact same syntax to wrap the code."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ It matches the following description: '{executor_description}'.
|
|||||||
It will be tested with the following scenario: '{test_scenario}'.
|
It will be tested with the following scenario: '{test_scenario}'.
|
||||||
For the implementation use the following package: '{package}'.
|
For the implementation use the following package: '{package}'.
|
||||||
Have in mind that d.uri is never a path to a local file. It is always a url.
|
Have in mind that d.uri is never a path to a local file. It is always a url.
|
||||||
''' + not_allowed(),
|
''' + not_allowed_executor(),
|
||||||
EXECUTOR_FILE_TAG,
|
EXECUTOR_FILE_TAG,
|
||||||
EXECUTOR_FILE_NAME
|
EXECUTOR_FILE_NAME
|
||||||
)
|
)
|
||||||
@@ -56,7 +56,7 @@ def test_executor_file_task(executor_name, test_scenario):
|
|||||||
)
|
)
|
||||||
+ "Use the following import to import the executor: "
|
+ "Use the following import to import the executor: "
|
||||||
f"```\nfrom microservice import {executor_name}\n```"
|
f"```\nfrom microservice import {executor_name}\n```"
|
||||||
+ not_allowed()
|
+ not_allowed_executor()
|
||||||
+ "The test must not open local files. "
|
+ "The test must not open local files. "
|
||||||
+ "The test must not mock a function of the executor. "
|
+ "The test must not mock a function of the executor. "
|
||||||
+ "The test must not use other data than the one provided in the test scenario. ",
|
+ "The test must not use other data than the one provided in the test scenario. ",
|
||||||
@@ -78,7 +78,6 @@ def requirements_file_task():
|
|||||||
def docker_file_task():
|
def docker_file_task():
|
||||||
return _task(
|
return _task(
|
||||||
"Write the Dockerfile that defines the environment with all necessary dependencies that the executor uses. "
|
"Write the Dockerfile that defines the environment with all necessary dependencies that the executor uses. "
|
||||||
"The Dockerfile runs the test during the build process. "
|
|
||||||
"It is important to make sure that all libs are installed that are required by the python packages. "
|
"It is important to make sure that all libs are installed that are required by the python packages. "
|
||||||
"Usually libraries are installed with apt-get. "
|
"Usually libraries are installed with apt-get. "
|
||||||
"Be aware that the machine the docker container is running on does not have a GPU - only CPU. "
|
"Be aware that the machine the docker container is running on does not have a GPU - only CPU. "
|
||||||
@@ -87,7 +86,7 @@ def docker_file_task():
|
|||||||
"The base image of the Dockerfile is FROM jinaai/jina:3.14.1-py39-standard. "
|
"The base image of the Dockerfile is FROM jinaai/jina:3.14.1-py39-standard. "
|
||||||
'The entrypoint is ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]. '
|
'The entrypoint is ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]. '
|
||||||
'Make sure the all files are in the /workdir. '
|
'Make sure the all files are in the /workdir. '
|
||||||
"The Dockerfile runs the test during the build process. ",
|
"The Dockerfile runs the test during the build process. " + not_allowed_docker(),
|
||||||
DOCKER_FILE_TAG,
|
DOCKER_FILE_TAG,
|
||||||
DOCKER_FILE_NAME
|
DOCKER_FILE_NAME
|
||||||
)
|
)
|
||||||
@@ -110,11 +109,12 @@ def streamlit_file_task():
|
|||||||
|
|
||||||
|
|
||||||
def chain_of_thought_creation():
|
def chain_of_thought_creation():
|
||||||
return (
|
return (f'''
|
||||||
"First, write down some non-obvious thoughts about the challenges of the task and give multiple approaches on how you handle them. "
|
First, write down some non-obvious thoughts about the challenges of the task and give multiple approaches on how you handle them.
|
||||||
"For example, the given package you could used in different ways and not all of them obay the rules: "
|
For example, the given package you could used in different ways and not all of them obey the instructions.
|
||||||
+ "Discuss the pros and cons for all of these approaches and then decide for one of the approaches. "
|
Discuss the pros and cons for all of these approaches and then decide for one of the approaches.
|
||||||
"Then write as I told you. "
|
Then write the code.
|
||||||
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ def chain_of_thought_optimization(tag_name, file_name, file_name_function=None):
|
|||||||
file_name_function
|
file_name_function
|
||||||
)
|
)
|
||||||
|
|
||||||
def not_allowed():
|
def not_allowed_executor():
|
||||||
return '''
|
return '''
|
||||||
The executor must not use the GPU.
|
The executor must not use the GPU.
|
||||||
The executor must not access a database.
|
The executor must not access a database.
|
||||||
@@ -145,5 +145,10 @@ The executor must not load data from the local file system unless it was created
|
|||||||
The executor must not use a pre-trained model unless it is explicitly mentioned in the description.
|
The executor must not use a pre-trained model unless it is explicitly mentioned in the description.
|
||||||
The executor must not train a model.
|
The executor must not train a model.
|
||||||
The executor must not use any attribute of Document accept Document.text.
|
The executor must not use any attribute of Document accept Document.text.
|
||||||
Note that the Dockerfile only has access to the files: executor.py, requirements.txt, config.yml, test_executor.py.
|
'''
|
||||||
|
|
||||||
|
def not_allowed_docker():
|
||||||
|
return '''
|
||||||
|
Note that the Dockerfile only has access to the files: executor.py, requirements.txt, config.yml, test_executor.py.
|
||||||
|
Note that the Dockerfile runs the test_microservice.py during the build process.
|
||||||
'''
|
'''
|
||||||
Reference in New Issue
Block a user