mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-23 08:34:20 +01:00
feat: chain of thought
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from src.constants import EXECUTOR_FILE_NAME, REQUIREMENTS_FILE_NAME, TEST_EXECUTOR_FILE_NAME, DOCKER_FILE_NAME, \
|
||||
DOCKER_FILE_TAG, CLIENT_FILE_TAG, CLIENT_FILE_NAME
|
||||
DOCKER_FILE_TAG, CLIENT_FILE_TAG, CLIENT_FILE_NAME, STREAMLIT_FILE_TAG, STREAMLIT_FILE_NAME, EXECUTOR_FILE_TAG, \
|
||||
REQUIREMENTS_FILE_TAG, TEST_EXECUTOR_FILE_TAG
|
||||
|
||||
|
||||
def general_guidelines():
|
||||
return (
|
||||
"General guidelines: "
|
||||
"The code you write is production ready. "
|
||||
"Every file starts with comments describing what the code is doing before the first import. "
|
||||
"Comments can only be written between tags. "
|
||||
@@ -20,7 +20,13 @@ def general_guidelines():
|
||||
|
||||
|
||||
def _task(task, tag_name, file_name):
|
||||
return task + f"The code will go into {file_name}. Wrap the code in the string $$$start_{tag_name}$$$...$$$end_{tag_name}$$$ \n\n"
|
||||
return (
|
||||
task + f"The code will go into {file_name}. Wrap the code is wrapped into:\n"
|
||||
f"**{file_name}**\n"
|
||||
f"```{tag_name}\n"
|
||||
f"...code...\n"
|
||||
f"```\n\n"
|
||||
)
|
||||
|
||||
|
||||
def executor_file_task(executor_name, executor_description, input_modality, input_doc_field,
|
||||
@@ -31,28 +37,31 @@ def executor_file_task(executor_name, executor_description, input_modality, inpu
|
||||
f"It gets a DocumentArray as input where each document has the input modality '{input_modality}' that is stored in document.{input_doc_field}. "
|
||||
f"It returns a DocumentArray as output where each document has the output modality '{output_modality}' that is stored in document.{output_doc_field}. "
|
||||
f"Have in mind that d.uri is never a path to a local file. It is always a url.",
|
||||
'executor',
|
||||
EXECUTOR_FILE_TAG,
|
||||
EXECUTOR_FILE_NAME
|
||||
)
|
||||
|
||||
|
||||
def requirements_file_task():
|
||||
return _task("Write the content of the requirements.txt file. "
|
||||
"Make sure to include pytest. "
|
||||
"All versions are fixed. ", 'requirements',
|
||||
REQUIREMENTS_FILE_NAME)
|
||||
return _task(
|
||||
"Write the content of the requirements.txt file. "
|
||||
"Make sure to include pytest. "
|
||||
"All versions are fixed. ",
|
||||
REQUIREMENTS_FILE_TAG,
|
||||
REQUIREMENTS_FILE_NAME
|
||||
)
|
||||
|
||||
|
||||
def test_executor_file_task(executor_name, test_in, test_out):
|
||||
return _task(
|
||||
"Write a small unit test for the executor. "
|
||||
"Start the test with an extensive comment about the test case. "
|
||||
+ (
|
||||
"Test that the executor converts the input '" + test_in + "' to the output '" + test_out + "'. "
|
||||
) if test_in and test_out else ""
|
||||
"Use the following import to import the executor: "
|
||||
f"from executor import {executor_name} ",
|
||||
'test_executor',
|
||||
+ ((
|
||||
"Test that the executor converts the input '" + test_in + "' to the output '" + test_out + "'. "
|
||||
) if test_in and test_out else "")
|
||||
+ "Use the following import to import the executor: "
|
||||
f"from executor import {executor_name} ",
|
||||
TEST_EXECUTOR_FILE_TAG,
|
||||
TEST_EXECUTOR_FILE_NAME
|
||||
)
|
||||
|
||||
@@ -66,12 +75,23 @@ def docker_file_task():
|
||||
"Add the config.yml file to the Dockerfile. "
|
||||
"The base image of the Dockerfile is FROM jinaai/jina:3.14.2-dev18-py310-standard. "
|
||||
'The entrypoint is ENTRYPOINT ["jina", "executor", "--uses", "config.yml"] '
|
||||
"The Dockerfile runs the test during the build process. "
|
||||
, DOCKER_FILE_TAG, DOCKER_FILE_NAME)
|
||||
"The Dockerfile runs the test during the build process. ",
|
||||
DOCKER_FILE_TAG,
|
||||
DOCKER_FILE_NAME
|
||||
)
|
||||
|
||||
|
||||
def client_file_task():
|
||||
return _task(
|
||||
"Write the client file. "
|
||||
, CLIENT_FILE_TAG, CLIENT_FILE_NAME
|
||||
"Write the client file. ",
|
||||
CLIENT_FILE_TAG,
|
||||
CLIENT_FILE_NAME
|
||||
)
|
||||
|
||||
|
||||
def streamlit_file_task():
|
||||
return _task(
|
||||
"Write the streamlit file allowing to make requests . ",
|
||||
STREAMLIT_FILE_TAG,
|
||||
STREAMLIT_FILE_NAME
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user