mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-20 23:24:20 +01:00
⏪ fix: fix bring back the test description for func generation
This commit is contained in:
@@ -72,8 +72,8 @@ you need to set the GOOGLE_API_KEY and GOOGLE_CSE_ID environment variables.
|
|||||||
More information can be found [here](https://developers.google.com/custom-search/v1/overview).
|
More information can be found [here](https://developers.google.com/custom-search/v1/overview).
|
||||||
```bash
|
```bash
|
||||||
dev-gpt configure --openai_api_key <your openai api key>
|
dev-gpt configure --openai_api_key <your openai api key>
|
||||||
dev-gpt configure --google_api_key <google api key> (optional if you want to use google search)
|
dev-gpt configure --google_api_key <google api key> (optional if you want to use google custom search)
|
||||||
dev-gpt configure --google_cse_id <google cse id> (optional if you want to use google search)
|
dev-gpt configure --google_cse_id <google cse id> (optional if you want to use google custom search)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you set the environment variable `OPENAI_API_KEY`, the configuration step can be skipped.
|
If you set the environment variable `OPENAI_API_KEY`, the configuration step can be skipped.
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ Note: the output must be a list of tasks the Microservice has to perform.
|
|||||||
Note: you must uses the following tools if necessary:
|
Note: you must uses the following tools if necessary:
|
||||||
{get_available_tools()}
|
{get_available_tools()}
|
||||||
Example for the description: "return an image representing the current weather for a given location." \
|
Example for the description: "return an image representing the current weather for a given location." \
|
||||||
when the tools gpt-3.5-turbo and google-search are available:
|
when the tools gpt_3_5_turbo and google_custom_search are available:
|
||||||
1. get the current weather information from the https://openweathermap.org/ API
|
1. get the current weather information from the https://openweathermap.org/ API
|
||||||
2. generate a Google search query to find the image matching the weather information and the location by using gpt-3.5-turbo (a)
|
2. generate a Google search query to find the image matching the weather information and the location by using gpt_3_5_turbo (a)
|
||||||
3. find the image by using the Google search API (b)
|
3. find the image by using the google_custom_search (b)
|
||||||
4. return the image as a base64 encoded string'''
|
4. return the image as a base64 encoded string'''
|
||||||
|
|
||||||
generate_request_schema_prompt = '''{context_string}
|
generate_request_schema_prompt = '''{context_string}
|
||||||
@@ -59,5 +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 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 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.'''
|
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.'''
|
||||||
|
|||||||
@@ -523,15 +523,19 @@ pytest
|
|||||||
file_name_s=['strategies.json'],
|
file_name_s=['strategies.json'],
|
||||||
description=self.microservice_specification.task
|
description=self.microservice_specification.task
|
||||||
)['strategies.json']
|
)['strategies.json']
|
||||||
packages_list = [[pkg.strip().lower() for pkg in packages] for packages in json.loads(packages_json_string)]
|
packages_list = self.process_packages_json_string(packages_json_string)
|
||||||
packages_list = [[self.replace_with_tool_if_possible(pkg) for pkg in packages] for packages in
|
|
||||||
packages_list]
|
|
||||||
|
|
||||||
packages_list = self.filter_packages_list(packages_list)
|
|
||||||
packages_list = self.remove_duplicates_from_packages_list(packages_list)
|
|
||||||
packages_list = packages_list[:NUM_IMPLEMENTATION_STRATEGIES]
|
|
||||||
return packages_list
|
return packages_list
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_packages_json_string(packages_json_string):
|
||||||
|
packages_list = [[pkg.strip().lower().replace('-', '_') for pkg in packages] for packages in json.loads(packages_json_string)]
|
||||||
|
packages_list = [[Generator.replace_with_tool_if_possible(pkg) for pkg in packages] for packages in
|
||||||
|
packages_list]
|
||||||
|
|
||||||
|
packages_list = Generator.filter_packages_list(packages_list)
|
||||||
|
packages_list = Generator.remove_duplicates_from_packages_list(packages_list)
|
||||||
|
packages_list = packages_list[:NUM_IMPLEMENTATION_STRATEGIES]
|
||||||
|
return packages_list
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
os.makedirs(self.microservice_root_path)
|
os.makedirs(self.microservice_root_path)
|
||||||
@@ -592,6 +596,7 @@ You can now run or deploy your microservice:
|
|||||||
and ( # all packages must be on pypi or it is gpt_3_5_turbo
|
and ( # all packages must be on pypi or it is gpt_3_5_turbo
|
||||||
is_package_on_pypi(package)
|
is_package_on_pypi(package)
|
||||||
or package == 'gpt_3_5_turbo'
|
or package == 'gpt_3_5_turbo'
|
||||||
|
or package == 'google_custom_search'
|
||||||
)
|
)
|
||||||
] for packages in packages_list
|
] for packages in packages_list
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ Description of the microservice:
|
|||||||
'Microservice description': 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 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.',
|
||||||
extension_name='Example of API usage',
|
extension_name='Example of API usage',
|
||||||
post_transformation_fn=translation(from_format='api instruction', to_format='python code snippet raw without formatting')
|
post_transformation_fn=translation(from_format='api instruction', to_format='python code snippet raw without formatting')
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ 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')
|
tools.append('google_custom_search (for retrieving images or textual information from google')
|
||||||
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)])
|
||||||
20
test/unit/test_packages.py
Normal file
20
test/unit/test_packages.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
from dev_gpt.options.generate.generator import Generator
|
||||||
|
|
||||||
|
def test_package_parsing():
|
||||||
|
packages_json_string = '''\
|
||||||
|
[
|
||||||
|
["PyPDF2", "gpt_3_5_turbo"],
|
||||||
|
["pdfminer.six", "gpt_3_5_turbo"],
|
||||||
|
["tika", "gpt_3_5_turbo"],
|
||||||
|
[],
|
||||||
|
["gpt_3_5_turbo"]
|
||||||
|
]'''
|
||||||
|
|
||||||
|
parsed_packages = Generator.process_packages_json_string(packages_json_string)
|
||||||
|
for parsed, expected in zip(parsed_packages, [
|
||||||
|
['pypdf2', 'gpt_3_5_turbo'],
|
||||||
|
['pdfminer.six', 'gpt_3_5_turbo'],
|
||||||
|
[],
|
||||||
|
['gpt_3_5_turbo'],
|
||||||
|
]):
|
||||||
|
assert set(parsed) == set(expected)
|
||||||
Reference in New Issue
Block a user