mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-19 14:44:20 +01:00
➕ refactor: summarize error message without line number
This commit is contained in:
@@ -64,7 +64,9 @@ Description of the microservice:
|
|||||||
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',
|
||||||
)
|
)
|
||||||
used_apis_beside_tools = [x for x in self.get_used_apis(microservice_description) if x not in ['google_custom_search', 'gpt_3_5_turbo']]
|
used_apis_beside_tools = [
|
||||||
|
x for x in self.get_used_apis(microservice_description) if any(t in x.lower() for t in ['gpt', 'search', 'google'])
|
||||||
|
]
|
||||||
for api in used_apis_beside_tools:
|
for api in used_apis_beside_tools:
|
||||||
microservice_description += self.user_input_extension_if_needed(
|
microservice_description += self.user_input_extension_if_needed(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -554,6 +554,7 @@ Microservice description:
|
|||||||
|
|
||||||
Question:
|
Question:
|
||||||
Respond with a list as JSON indicating which web APIs (e.g. google_custom_search, gpt_3_5_turbo) are mentioned in the description.
|
Respond with a list as JSON indicating which web APIs (e.g. google_custom_search, gpt_3_5_turbo) are mentioned in the description.
|
||||||
|
Note that local libraries are not web APIs and must not be mentioned.
|
||||||
Positive Example 1:
|
Positive Example 1:
|
||||||
{{
|
{{
|
||||||
"mentioned_apis": ["google_custom_search", "gpt_3_5_turbo"]
|
"mentioned_apis": ["google_custom_search", "gpt_3_5_turbo"]
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ def test_no_search():
|
|||||||
tool_lines = get_available_tools().split('\n')
|
tool_lines = get_available_tools().split('\n')
|
||||||
assert len(tool_lines) == 1
|
assert len(tool_lines) == 1
|
||||||
|
|
||||||
def test_get_used_tools(tmpdir):
|
def test_get_used_apis(tmpdir):
|
||||||
os.environ['VERBOSE'] = 'true'
|
os.environ['VERBOSE'] = 'true'
|
||||||
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||||
used_tools = PM.get_used_apis('''\
|
used_apis = PM.get_used_apis('''\
|
||||||
This microservice listens for incoming requests and generates a fixed output of "test" upon receiving a request. \
|
This microservice listens for incoming requests and generates a fixed output of "test" upon receiving a request. \
|
||||||
The response sent back to the requester includes the output as a string parameter. \
|
The response sent back to the requester includes the output as a string parameter. \
|
||||||
No specific request parameters are required, and the response always follows a fixed schema with a single "output" parameter.'''
|
No specific request parameters are required, and the response always follows a fixed schema with a single "output" parameter.'''
|
||||||
)
|
)
|
||||||
assert used_tools == []
|
assert used_apis == []
|
||||||
|
|
||||||
def test_get_used_tools_2(tmpdir):
|
def test_get_used_apis_2(tmpdir):
|
||||||
os.environ['VERBOSE'] = 'true'
|
os.environ['VERBOSE'] = 'true'
|
||||||
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||||
description = '''\
|
description = '''\
|
||||||
@@ -36,5 +36,31 @@ This microservice accepts a 1-minute WAV audio file of speech, encoded as a base
|
|||||||
4. Encodes the resulting audio file as a base64 binary string.
|
4. Encodes the resulting audio file as a base64 binary string.
|
||||||
|
|
||||||
The microservice returns the summarized text converted to audio and encoded as a base64 binary string.'''
|
The microservice returns the summarized text converted to audio and encoded as a base64 binary string.'''
|
||||||
used_tools = PM.get_used_apis(description)
|
used_apis = PM.get_used_apis(description)
|
||||||
assert used_tools == ['Whisper API', 'gpt_3_5_turbo', 'text-to-speech (TTS) library']
|
assert used_apis == ['Whisper API', 'gpt_3_5_turbo', 'text-to-speech (TTS) library']
|
||||||
|
|
||||||
|
def test_get_used_apis_3(tmpdir):
|
||||||
|
os.environ['VERBOSE'] = 'true'
|
||||||
|
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||||
|
description = '''\
|
||||||
|
This microservice takes a PDF file as input and returns a summarized text output. \
|
||||||
|
It uses PDF parsing and natural language processing tools to generate the summary, \
|
||||||
|
and applies post-processing techniques to improve its quality. \
|
||||||
|
The input parameter is the PDF file, \
|
||||||
|
and the output parameter is the summarized text.'''
|
||||||
|
used_apis = PM.get_used_apis(description)
|
||||||
|
assert used_apis == []
|
||||||
|
|
||||||
|
def test_get_used_apis_4(tmpdir):
|
||||||
|
os.environ['VERBOSE'] = 'true'
|
||||||
|
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||||
|
description = '''\
|
||||||
|
This microservice receives a tweet as input \
|
||||||
|
and identifies passive aggressive language using natural language processing techniques. \
|
||||||
|
It then generates a positive version of the tweet using a text processing tool such as GPT-3. \
|
||||||
|
The positive version of the tweet is returned as output. \
|
||||||
|
The input tweet should be provided as a base64 encoded string \
|
||||||
|
and the output positive tweet will also be returned as a base64 encoded string.'''
|
||||||
|
used_apis = PM.get_used_apis(description)
|
||||||
|
assert used_apis == ['GPT-3']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user