mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-21 15:44:19 +01:00
feat: search fix web search
This commit is contained in:
@@ -257,11 +257,12 @@ metas:
|
|||||||
print('\nFirst version of the microservice generated. Start iterating on it to make the tests pass...')
|
print('\nFirst version of the microservice generated. Start iterating on it to make the tests pass...')
|
||||||
|
|
||||||
|
|
||||||
def add_missing_imports_post_process_fn(self, content_raw: str):
|
def add_missing_imports_post_process_fn(self, content_dict: dict):
|
||||||
for indicator, import_statement in INDICATOR_TO_IMPORT_STATEMENT.items():
|
for indicator, import_statement in INDICATOR_TO_IMPORT_STATEMENT.items():
|
||||||
if indicator in content_raw and import_statement not in content_raw:
|
for file_name, file_content in content_dict.items():
|
||||||
content_raw = f'{import_statement}\n{content_raw}'
|
if indicator in file_content and import_statement not in file_content:
|
||||||
return content_raw
|
content_dict[file_name] = f'{import_statement}\n{file_content}'
|
||||||
|
return content_dict
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
|
|||||||
|
|
||||||
|
|
||||||
class GPT_3_5_Turbo:
|
class GPT_3_5_Turbo:
|
||||||
def __init__(self, system: str = ''):
|
def __init__(self, system_string: str = ''):
|
||||||
self.system = system
|
self.system = system_string
|
||||||
|
|
||||||
def __call__(self, prompt: str) -> str:
|
def __call__(self, prompt_string: str) -> str:
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
model="gpt-3.5-turbo",
|
model="gpt-3.5-turbo",
|
||||||
messages=[{
|
messages=[{
|
||||||
@@ -17,7 +17,7 @@ class GPT_3_5_Turbo:
|
|||||||
"content": self.system
|
"content": self.system
|
||||||
}, {
|
}, {
|
||||||
"role": 'user',
|
"role": 'user',
|
||||||
"content": prompt
|
"content": prompt_string
|
||||||
}]
|
}]
|
||||||
)
|
)
|
||||||
return response.choices[0]['message']['content']
|
return response.choices[0]['message']['content']
|
||||||
|
|||||||
@@ -97,13 +97,13 @@ gpt_35_turbo_usage_string = """If you need to use gpt_3_5_turbo, then use it lik
|
|||||||
from .apis import GPT_3_5_Turbo
|
from .apis import GPT_3_5_Turbo
|
||||||
|
|
||||||
gpt_3_5_turbo = GPT_3_5_Turbo(
|
gpt_3_5_turbo = GPT_3_5_Turbo(
|
||||||
system=\'\'\'
|
system_string=\'\'\'
|
||||||
You are a tv-reporter who is specialized in C-list celebrities.
|
You are a tv-reporter who is specialized in C-list celebrities.
|
||||||
When you get asked something like 'Who was having a date with <X>?', then you answer with a json like '{{"dates": ["<Y>", "<Z>"]}}'.
|
When you get asked something like 'Who was having a date with <X>?', then you answer with a json like '{{"dates": ["<Y>", "<Z>"]}}'.
|
||||||
You must not answer something else - only the json.
|
You must not answer something else - only the json.
|
||||||
\'\'\')
|
\'\'\')
|
||||||
|
|
||||||
generated_string = gpt_3_5_turbo("example user prompt") # prompt is a string; generated_string is a string
|
generated_string = gpt_3_5_turbo(prompt_string="example user prompt") # prompt_string is the only parameter
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ def test_generation_level_0(microservice_dir, mock_input_sequence):
|
|||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('mock_input_sequence', [['y']], indirect=True)
|
@pytest.mark.parametrize('mock_input_sequence', [['y']], indirect=True)
|
||||||
def test_generation_level_1(microservice_dir, mock_input_sequence):
|
def test_generation_level_1(microservice_dir, mock_input_sequence):
|
||||||
"""
|
"""
|
||||||
@@ -48,12 +47,13 @@ Example tweet:
|
|||||||
But hey, at least SOMEONE's enjoying their lunch. #officelife\'''',
|
But hey, at least SOMEONE's enjoying their lunch. #officelife\'''',
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('mock_input_sequence', [['y', 'https://www.africau.edu/images/default/sample.pdf']], indirect=True)
|
@pytest.mark.parametrize('mock_input_sequence', [['y', 'https://www.africau.edu/images/default/sample.pdf']],
|
||||||
|
indirect=True)
|
||||||
def test_generation_level_2(microservice_dir, mock_input_sequence):
|
def test_generation_level_2(microservice_dir, mock_input_sequence):
|
||||||
"""
|
"""
|
||||||
Requirements:
|
Requirements:
|
||||||
@@ -69,11 +69,13 @@ def test_generation_level_2(microservice_dir, mock_input_sequence):
|
|||||||
"The input is a PDF and the output the summarized text (50 words).",
|
"The input is a PDF and the output the summarized text (50 words).",
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
@pytest.mark.parametrize('mock_input_sequence', [['y', 'https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png']], indirect=True)
|
|
||||||
|
@pytest.mark.parametrize('mock_input_sequence', [
|
||||||
|
['y', 'https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png']], indirect=True)
|
||||||
def test_generation_level_2_svg(microservice_dir, mock_input_sequence):
|
def test_generation_level_2_svg(microservice_dir, mock_input_sequence):
|
||||||
"""
|
"""
|
||||||
Requirements:
|
Requirements:
|
||||||
@@ -89,7 +91,7 @@ def test_generation_level_2_svg(microservice_dir, mock_input_sequence):
|
|||||||
"Get a png as input and return a vectorized version as svg.",
|
"Get a png as input and return a vectorized version as svg.",
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
@@ -116,10 +118,11 @@ Example input: 'AAPL'
|
|||||||
''',
|
''',
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'mock_input_sequence', [
|
'mock_input_sequence', [
|
||||||
[
|
[
|
||||||
@@ -161,10 +164,11 @@ def test_generation_level_4(microservice_dir, mock_input_sequence):
|
|||||||
''',
|
''',
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-4',
|
'gpt-4',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('mock_input_sequence', [['y']], indirect=True)
|
@pytest.mark.parametrize('mock_input_sequence', [['y']], indirect=True)
|
||||||
def test_generation_level_5_company_logos(microservice_dir, mock_input_sequence):
|
def test_generation_level_5_company_logos(microservice_dir, mock_input_sequence):
|
||||||
os.environ['VERBOSE'] = 'true'
|
os.environ['VERBOSE'] = 'true'
|
||||||
@@ -177,11 +181,14 @@ The square is returned as png.
|
|||||||
''',
|
''',
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
@pytest.mark.parametrize('mock_input_sequence', [['y', 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/560px-PNG_transparency_demonstration_1.png']], indirect=True)
|
|
||||||
|
@pytest.mark.parametrize('mock_input_sequence', [['y',
|
||||||
|
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/560px-PNG_transparency_demonstration_1.png']],
|
||||||
|
indirect=True)
|
||||||
def test_generation_level_5(microservice_dir, mock_input_sequence):
|
def test_generation_level_5(microservice_dir, mock_input_sequence):
|
||||||
"""
|
"""
|
||||||
Requirements:
|
Requirements:
|
||||||
@@ -193,7 +200,8 @@ def test_generation_level_5(microservice_dir, mock_input_sequence):
|
|||||||
Databases: ❌
|
Databases: ❌
|
||||||
"""
|
"""
|
||||||
os.environ['VERBOSE'] = 'true'
|
os.environ['VERBOSE'] = 'true'
|
||||||
generator = Generator(f'''
|
generator = Generator(
|
||||||
|
f'''
|
||||||
The input is an image.
|
The input is an image.
|
||||||
Use the following api to get the description of the image:
|
Use the following api to get the description of the image:
|
||||||
Request:
|
Request:
|
||||||
@@ -217,7 +225,7 @@ The output is the image with the joke on it.
|
|||||||
''',
|
''',
|
||||||
str(microservice_dir),
|
str(microservice_dir),
|
||||||
'gpt-3.5-turbo',
|
'gpt-3.5-turbo',
|
||||||
self_healing=False,
|
# self_healing=False,
|
||||||
)
|
)
|
||||||
assert generator.generate() == 0
|
assert generator.generate() == 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user