fix: review

This commit is contained in:
Joschka Braun
2023-04-18 16:04:58 +02:00
parent a4d3a9f869
commit f6ed24e738
4 changed files with 12 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ from openai.error import RateLimitError
from langchain.schema import AIMessage, HumanMessage, SystemMessage, BaseMessage
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from src.options.generate.prompt_system import system_message_base, executor_example, docarray_example, client_example
from src.options.generate.templates_system import template_system_message_base, executor_example, docarray_example, client_example
from src.utils.string_tools import print_colored
@@ -84,12 +84,14 @@ class _GPTConversation:
print_colored('user', prompt, 'blue')
print_colored('assistant', '', 'green', end='')
response = self._chat([self.system_message] + self.messages)
if os.environ['VERBOSE'].lower() == 'true':
print()
self.messages.append(response)
return response.content
@staticmethod
def _create_system_message(task_description, test_description, system_definition_examples: List[str] = []) -> SystemMessage:
system_message = PromptTemplate.from_template(system_message_base).format(
system_message = PromptTemplate.from_template(template_system_message_base).format(
task_description=task_description,
test_description=test_description,
)

View File

@@ -7,7 +7,7 @@ from src.apis.jina_cloud import process_error_message, push_executor
from src.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS, \
PROBLEMATIC_PACKAGES, EXECUTOR_FILE_NAME, EXECUTOR_FILE_TAG, TEST_EXECUTOR_FILE_NAME, TEST_EXECUTOR_FILE_TAG, \
REQUIREMENTS_FILE_NAME, REQUIREMENTS_FILE_TAG, DOCKER_FILE_NAME, DOCKER_FILE_TAG
from src.options.generate.templates import template_generate_microservice_name, template_generate_possible_packages, \
from src.options.generate.templates_user import template_generate_microservice_name, template_generate_possible_packages, \
template_solve_code_issue, \
template_solve_dependency_issue, template_is_dependency_issue, template_generate_playground, \
template_generate_executor, template_generate_test, template_generate_requirements, template_generate_dockerfile, \

View File

@@ -1,5 +1,5 @@
from src.constants import FLOW_URL_PLACEHOLDER
from src.options.generate.templates import not_allowed_docker_string, not_allowed_executor_string
from src.options.generate.templates_user import not_allowed_docker_string, not_allowed_executor_string
executor_example = '''Using the Jina framework, users can define executors.
Here is an example of how an executor can be defined. It always starts with a comment:
@@ -72,16 +72,18 @@ print(response[0].text)
```'''
system_message_base = '''It is the year 2021.
template_system_message_base = f'''It is the year 2021.
You are a principal engineer working at Jina - an open source company.
You accurately satisfy all of the user's requirements.
To be more specific, you help the user to build a microservice with the following requirements:
```
{task_description}
{{task_description}}
```
and the following test scenario:
```
{test_description}
{{test_description}}
```
You must obey the following rules:''' + f'\n{not_allowed_executor_string}\n{not_allowed_docker_string}'
You must obey the following rules:
{not_allowed_executor_string}
{not_allowed_docker_string}'''