mirror of
https://github.com/aljazceru/dev-gpt.git
synced 2025-12-27 10:24:28 +01:00
➕ refactor: summarize error message without line number
This commit is contained in:
@@ -20,8 +20,23 @@ def google_search(search_term, search_type, top_n):
|
||||
return response.json()
|
||||
|
||||
def search_images(search_term, top_n):
|
||||
response = google_search(search_term, search_type="image", top_n=top_n)
|
||||
return [item["link"] for item in response["items"]]
|
||||
"""
|
||||
Returns only images that have a 200 response code.
|
||||
"""
|
||||
response = google_search(search_term, search_type="image", top_n=10)
|
||||
image_urls = []
|
||||
for item in response["items"]:
|
||||
if len(image_urls) >= top_n:
|
||||
break
|
||||
try:
|
||||
response = requests.head(item["link"], timeout=2)
|
||||
if response.status_code == 200:
|
||||
image_urls.append(
|
||||
item["link"]
|
||||
)
|
||||
except requests.exceptions.RequestException:
|
||||
pass
|
||||
return image_urls
|
||||
|
||||
def search_web(search_term, top_n):
|
||||
response = google_search(search_term, search_type="web", top_n=top_n)
|
||||
|
||||
@@ -129,17 +129,9 @@ Example input: 'AAPL'
|
||||
'y',
|
||||
'https://www2.cs.uic.edu/~i101/SoundFiles/taunt.wav',
|
||||
f'''\
|
||||
import requests
|
||||
url = "https://transcribe.whisperapi.com"
|
||||
headers = {{
|
||||
'Authorization': 'Bearer {os.environ['WHISPER_API_KEY']}'
|
||||
}}
|
||||
data = {{
|
||||
"url": "URL_OF_STORED_AUDIO_FILE"
|
||||
}}
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
assert response.status_code == 200
|
||||
print('This is the text from the audio file:', response.text)'''
|
||||
import openai
|
||||
audio_file= open("/path/to/file/audio.mp3", "rb")
|
||||
transcript = openai.Audio.transcribe("whisper-1", audio_file)'''
|
||||
]
|
||||
],
|
||||
indirect=True
|
||||
@@ -158,12 +150,12 @@ def test_generation_level_4(microservice_dir, mock_input_sequence):
|
||||
generator = Generator(
|
||||
f'''Given an audio file (1min wav) of speech,
|
||||
1. convert it to text using the Whisper API.
|
||||
2. Summarize the text (~50 words) while still maintaining the key facts.
|
||||
2. Summarize the text while still maintaining the key facts.
|
||||
3. Create an audio file of the summarized text using a tts library.
|
||||
4. Return the the audio file as base64 encoded binary.
|
||||
''',
|
||||
str(microservice_dir),
|
||||
'gpt-4',
|
||||
'gpt-3.5-turbo',
|
||||
# self_healing=False,
|
||||
)
|
||||
assert generator.generate() == 0
|
||||
|
||||
Reference in New Issue
Block a user