fix: fix bring back the test description for func generation

This commit is contained in:
Florian Hönicke
2023-05-25 21:23:38 +02:00
parent 8d529a6d18
commit 3911f8bf89
5 changed files with 18 additions and 16 deletions

View File

@@ -182,7 +182,7 @@ def ask_gpt(prompt_template: str, parser=identity_parser, **kwargs):
kwargs[key] = json.dumps(value, indent=4) kwargs[key] = json.dumps(value, indent=4)
prompt = prompt_template.format(**kwargs) prompt = prompt_template.format(**kwargs)
conversation = GPTSession._instance.get_conversation( conversation = GPTSession._instance.get_conversation(
[], [SystemMessage(content='You are a helpful AI assistant that follows instructions from the user exactly.')],
print_stream=os.environ['VERBOSE'].lower() == 'true', print_stream=os.environ['VERBOSE'].lower() == 'true',
print_costs=False print_costs=False
) )

View File

@@ -59,4 +59,5 @@ Write an updated microservice description by incorporating information about the
Note: You must not mention any details about algorithms or the technical implementation. Note: You must not mention any details about algorithms or the technical implementation.
Note: You must not mention that there is a request and response JSON schema Note: You must not mention that there is a request and response JSON schema
Note: You must not use any formatting like triple backticks. Note: You must not use any formatting like triple backticks.
Note: If an external API is mentioned in the description, then you must mention the API in the updated description as well.''' Note: If Google Custom Search or gpt-3.5-turbo is mentioned in the description, then you must mention them in the updated description as well.
Note: If an external API besides Google Custom Search and gpt-3.5-turbo is mentioned in the description, then you must mention the API in the updated description as well.'''

View File

@@ -38,9 +38,11 @@ Note: You must not answer the question. Instead, give up to 5 bullet points (10
question_prompt = '''\ question_prompt = '''\
# Context # Context
{text} {text}
# Question
{question}
# Pros and Cons # Pros and Cons
{pros_and_cons} {pros_and_cons}
Note: You must answer "yes" or "no".
# Question
Based on the pros and cons, answer the following question: {question}
Note: You must answer the question correctly by saying "yes" or "no".
''' '''

View File

@@ -52,15 +52,19 @@ Description of the microservice:
) )
test_description += self.user_input_extension_if_needed( test_description += self.user_input_extension_if_needed(
context, {
microservice_description, 'Microservice description': microservice_description,
'Request schema': context['request_schema'],
'Response schema': context['response_schema'],
},
condition_question='Does the request schema provided include a property that represents a file?', condition_question='Does the request schema provided include a property that represents a file?',
question_gen='Generate a question that requests for an example file url.', question_gen='Generate a question that requests for an example file url.',
extension_name='Input Example', extension_name='Input Example',
) )
microservice_description += self.user_input_extension_if_needed( microservice_description += self.user_input_extension_if_needed(
context, {
microservice_description, 'Microservice description': microservice_description,
},
condition_question='''\ condition_question='''\
Does the microservice send requests to an API beside the Google Custom Search API and gpt-3.5-turbo?''', Does the microservice send requests to an API beside the Google Custom Search API and gpt-3.5-turbo?''',
question_gen='Generate a question that asks for the endpoint of the external API and an example of a request and response when interacting with the external API.', question_gen='Generate a question that asks for the endpoint of the external API and an example of a request and response when interacting with the external API.',
@@ -72,18 +76,13 @@ Does the microservice send requests to an API beside the Google Custom Search AP
def user_input_extension_if_needed( def user_input_extension_if_needed(
self, self,
context, context,
microservice_description,
condition_question, condition_question,
question_gen, question_gen,
extension_name, extension_name,
post_transformation_fn=None post_transformation_fn=None
): ):
user_answer = get_user_input_if_needed( user_answer = get_user_input_if_needed(
context={ context=context,
'Microservice description': microservice_description,
'Request schema': context['request_schema'],
'Response schema': context['response_schema'],
},
conditions=[ conditions=[
is_question_true(condition_question), is_question_true(condition_question),
], ],

View File

@@ -4,6 +4,6 @@ import os
def get_available_tools(): def get_available_tools():
tools = ['gpt-3.5-turbo (for any kind of text processing like summarization, paraphrasing, etc.)'] tools = ['gpt-3.5-turbo (for any kind of text processing like summarization, paraphrasing, etc.)']
if os.environ.get('GOOGLE_API_KEY') and os.environ.get('GOOGLE_CSE_ID'): if os.environ.get('GOOGLE_API_KEY') and os.environ.get('GOOGLE_CSE_ID'):
tools.append('Google Custom Search API') tools.append('Google Custom Search')
chars = 'abcdefghijklmnopqrstuvwxyz' chars = 'abcdefghijklmnopqrstuvwxyz'
return '\n'.join([f'{char}) {tool}' for tool, char in zip(tools, chars)]) return '\n'.join([f'{char}) {tool}' for tool, char in zip(tools, chars)])