mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-23 16:44:20 +01:00
➕ refactor: summarize error message without line number
This commit is contained in:
@@ -17,8 +17,7 @@ def boolean_parser(x):
|
||||
return 'yes' in x.lower()
|
||||
|
||||
def json_parser(x):
|
||||
if '```' in x:
|
||||
pattern = r'([\[\{].+[\]\}])'
|
||||
pattern = r'([\[\{].*[\]\}])'
|
||||
x = re.findall(pattern, x, re.DOTALL)[-1]
|
||||
return json.loads(x)
|
||||
|
||||
|
||||
@@ -78,7 +78,8 @@ Description of the microservice:
|
||||
)
|
||||
return microservice_description, test_description
|
||||
|
||||
def get_used_tools(self, microservice_description):
|
||||
@staticmethod
|
||||
def get_used_tools(microservice_description):
|
||||
return ask_gpt(
|
||||
generate_used_tools_prompt,
|
||||
self_healing_json_parser,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
|
||||
from dev_gpt.apis.gpt import GPTSession
|
||||
from dev_gpt.options.generate.pm.pm import PM
|
||||
from dev_gpt.options.generate.tools.tools import get_available_tools
|
||||
|
||||
|
||||
@@ -11,3 +13,13 @@ def test_no_search():
|
||||
os.environ['GOOGLE_API_KEY'] = ''
|
||||
tool_lines = get_available_tools().split('\n')
|
||||
assert len(tool_lines) == 1
|
||||
|
||||
def test_get_used_tools(tmpdir):
|
||||
os.environ['VERBOSE'] = 'true'
|
||||
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||
used_tools = PM.get_used_tools('''\
|
||||
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. \
|
||||
No specific request parameters are required, and the response always follows a fixed schema with a single "output" parameter.'''
|
||||
)
|
||||
assert used_tools == []
|
||||
Reference in New Issue
Block a user