🤏 refactor: simplify name

This commit is contained in:
Florian Hönicke
2023-05-23 00:17:53 +02:00
parent 8a3f55e6f4
commit 35264a8fcd
3 changed files with 14 additions and 21 deletions

View File

@@ -17,6 +17,7 @@ from urllib3.exceptions import InvalidChunkLength
from dev_gpt.constants import PRICING_GPT4_PROMPT, PRICING_GPT4_GENERATION, PRICING_GPT3_5_TURBO_PROMPT, \ from dev_gpt.constants import PRICING_GPT4_PROMPT, PRICING_GPT4_GENERATION, PRICING_GPT3_5_TURBO_PROMPT, \
PRICING_GPT3_5_TURBO_GENERATION, CHARS_PER_TOKEN PRICING_GPT3_5_TURBO_GENERATION, CHARS_PER_TOKEN
from dev_gpt.options.generate.conversation_logger import ConversationLogger from dev_gpt.options.generate.conversation_logger import ConversationLogger
from dev_gpt.options.generate.parser import identity_parser
from dev_gpt.options.generate.templates_system import template_system_message_base from dev_gpt.options.generate.templates_system import template_system_message_base
from dev_gpt.utils.string_tools import print_colored, get_template_parameters from dev_gpt.utils.string_tools import print_colored, get_template_parameters
@@ -170,7 +171,7 @@ class _GPTConversation:
return SystemMessage(content=system_message) return SystemMessage(content=system_message)
def ask_gpt(prompt_template, parser, **kwargs): def ask_gpt(prompt_template, parser=identity_parser, **kwargs):
template_parameters = get_template_parameters(prompt_template) template_parameters = get_template_parameters(prompt_template)
if set(template_parameters) != set(kwargs.keys()): if set(template_parameters) != set(kwargs.keys()):
raise ValueError( raise ValueError(

View File

@@ -12,7 +12,7 @@ from langchain.schema import SystemMessage, AIMessage
from pydantic.dataclasses import dataclass from pydantic.dataclasses import dataclass
from dev_gpt.apis import gpt from dev_gpt.apis import gpt
from dev_gpt.apis.gpt import _GPTConversation from dev_gpt.apis.gpt import _GPTConversation, ask_gpt
from dev_gpt.apis.jina_cloud import process_error_message, push_executor, is_executor_in_hub from dev_gpt.apis.jina_cloud import process_error_message, push_executor, is_executor_in_hub
from dev_gpt.apis.pypi import is_package_on_pypi, clean_requirements_txt from dev_gpt.apis.pypi import is_package_on_pypi, clean_requirements_txt
from dev_gpt.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS, \ from dev_gpt.constants import FILE_AND_TAG_PAIRS, NUM_IMPLEMENTATION_STRATEGIES, MAX_DEBUGGING_ITERATIONS, \
@@ -512,14 +512,7 @@ pytest
return 'yes' in answer.lower() return 'yes' in answer.lower()
def generate_microservice_name(self, description): def generate_microservice_name(self, description):
name = self.generate_and_persist_file( return ask_gpt(template_generate_microservice_name, description=description)
section_title='Generate microservice name',
template=template_generate_microservice_name,
destination_folder=self.microservice_root_path,
file_name_s=['name.txt'],
description=description
)['name.txt']
return name
def get_possible_packages(self): def get_possible_packages(self):
print_colored('', '\n\n############# What packages to use? #############', 'blue') print_colored('', '\n\n############# What packages to use? #############', 'blue')

View File

@@ -28,28 +28,27 @@ The implemented function and the test must not have a __main__ function.
The implemented function and the test must use gpt_3_5_turbo if the task requires the processing of language (e.g., understanding, generation, summarization, transformation, translation, modification or classification). Other language models are not allowed. The implemented function and the test must use gpt_3_5_turbo if the task requires the processing of language (e.g., understanding, generation, summarization, transformation, translation, modification or classification). Other language models are not allowed.
The implemented function must follow a clean and elegant coding style.''' The implemented function must follow a clean and elegant coding style.'''
plain_response_format_prompt = '''The response must be raw text and not fenced by markdown or html'''
template_generate_microservice_name = PromptTemplate.from_template( template_generate_microservice_name = PromptTemplate.from_template(
'''Generate a name for the executor matching the description: f'''Generate a name for the executor matching the description:
"{description}" "{{description}}"
The executor name must fulfill the following criteria: The executor name must fulfill the following criteria:
- camel case - camel case
- start with a capital letter - start with a capital letter
- only consists of lower and upper case characters - only consists of lower and upper case characters
- end with Executor. - end with Executor.
{plain_response_format_prompt}
Your response must exactly match the following block code format (double asterisks for the file name and triple backticks for the file block): Positive example:
**name.txt** PngToSvgExecutor
``` Negative example:
<name here>
```
Example for: "Get a png as input and return a vectorized version as svg.":
**name.txt**
``` ```
PngToSvgExecutor PngToSvgExecutor
```''' ```
'''
) )
# todo split into multiple calls. One for brainstorming - one for the final answer # todo split into multiple calls. One for brainstorming - one for the final answer
template_generate_possible_packages = PromptTemplate.from_template( template_generate_possible_packages = PromptTemplate.from_template(
'''Here is the task description of the problem you need to solve: '''Here is the task description of the problem you need to solve: