mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-21 15:44:19 +01:00
➕ refactor: summarize error message without line number
This commit is contained in:
@@ -53,6 +53,7 @@ BLACKLISTED_PACKAGES = [
|
||||
'clearbit', # because of installation issues on latest version
|
||||
'pyttsx3', # after engine.save_to_file(summarized_text, "summarized_audio.wav"); engine.runAndWait() "summarized_audio.wav" does not exist
|
||||
]
|
||||
|
||||
UNNECESSARY_PACKAGES = [
|
||||
'jinja2', 'werkzeug', 'flask', 'flask_restful', 'http.server', 'flask_json', 'flask_cors', 'fastapi', 'uvicorn', 'starlette', # because the wrappers are used instead
|
||||
'pypng', # if we provide access to the documentation all should be fine but for now it is too hard to use since the import is png
|
||||
@@ -70,3 +71,7 @@ SEARCH_PACKAGES = [
|
||||
'googlesearch-python', 'google', 'googlesearch', 'google-api-python-client', 'pygooglenews', 'google-cloud'
|
||||
]
|
||||
|
||||
TOOL_TO_ALIASES = {
|
||||
'gpt_3_5_turbo': ['gpt-3', 'GPT-3']
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
import json
|
||||
|
||||
from dev_gpt.apis.gpt import ask_gpt
|
||||
from dev_gpt.constants import TOOL_TO_ALIASES
|
||||
from dev_gpt.options.generate.parser import identity_parser, optional_tripple_back_tick_parser
|
||||
from dev_gpt.options.generate.prompt_factory import context_to_string
|
||||
from dev_gpt.options.generate.tools.tools import get_available_tools
|
||||
|
||||
|
||||
def auto_refine_description(context):
|
||||
context['microservice_description'] = ask_gpt(
|
||||
def enhance_description(context):
|
||||
enhanced_description = ask_gpt(
|
||||
better_description_prompt,
|
||||
identity_parser,
|
||||
context_string=context_to_string(context)
|
||||
)
|
||||
for tool_name, aliases in TOOL_TO_ALIASES.items():
|
||||
for alias in aliases:
|
||||
enhanced_description = enhanced_description.replace(alias, tool_name)
|
||||
return enhanced_description
|
||||
|
||||
|
||||
def auto_refine_description(context):
|
||||
context['microservice_description'] = enhance_description(context)
|
||||
context['request_schema'] = ask_gpt(
|
||||
generate_request_schema_prompt,
|
||||
optional_tripple_back_tick_parser,
|
||||
@@ -61,5 +69,4 @@ 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 that there is a request and response JSON schema
|
||||
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 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 like google_custom_search or gpt_3_5_turbo is mentioned in the description, then you must mention the API in the updated description as well.'''
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
|
||||
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, text classification, text generation etc.)']
|
||||
if os.environ.get('GOOGLE_API_KEY') and os.environ.get('GOOGLE_CSE_ID'):
|
||||
tools.append('google_custom_search (for retrieving images or textual information from google')
|
||||
chars = 'abcdefghijklmnopqrstuvwxyz'
|
||||
|
||||
14
test/unit/test_self_refinement.py
Normal file
14
test/unit/test_self_refinement.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
|
||||
from dev_gpt.apis.gpt import GPTSession
|
||||
from dev_gpt.options.generate.chains.auto_refine_description import enhance_description
|
||||
|
||||
|
||||
def test_better_description(tmpdir):
|
||||
os.environ['VERBOSE'] = 'true'
|
||||
GPTSession(os.path.join(str(tmpdir), 'log.json'), model='gpt-3.5-turbo')
|
||||
|
||||
better_description = enhance_description({
|
||||
'microservice_description': 'Input is a tweet that contains passive aggressive language. The output is the positive version of that tweet.'
|
||||
})
|
||||
assert 'gpt_3_5_turbo' in better_description
|
||||
Reference in New Issue
Block a user