Spaces:
Sleeping
Sleeping
Update main.py
Browse files198 unmodified lines199200201202203204205206207208209210211212213214215216217218198 unmodified linesdata['max_new_tokens'] = max(200, data['max_new_tokens'] - 200)else:data['max_new_tokens'] = data['max_new_tokens'] + 200for _ in range(max_retries):try:async with session.post(url, headers=headers, json=data) as response:response.raise_for_status()try:result_data = await response.json()except aiohttp.ContentTypeError:result_data = await response.text()return result_dataexcept (asyncio.TimeoutError, aiohttp.ClientError, requests.exceptions.HTTPError) as e:LoggaTesto("ERRORE ASYNC", {e}, False)if isinstance(e, (asyncio.TimeoutError, requests.exceptions.HTTPError)) and e.response.status in [502, 504]:breakawait asyncio.sleep(3)raise Exception("Max retries reached or skipping retries. Unable to make the request.")async def CreaListaInput(input_data):198 unmodified lines199200201202203204205206207208209210211212213214215216217218219198 unmodified linesdata['max_new_tokens'] = max(200, data['max_new_tokens'] - 200)else:data['max_new_tokens'] = data['max_new_tokens'] + 200timeout = aiohttp.ClientTimeout(total=1000)for _ in range(max_retries):try:async with session.post(url, headers=headers, json=data, timeout=timeout) as response:response.raise_for_status()try:result_data = await response.json()except aiohttp.ContentTypeError:result_data = await response.text()return result_dataexcept (asyncio.TimeoutError, aiohttp.ClientError) as e:LoggaTesto("ERRORE ASYNC", {str(e)}, False)if isinstance(e, aiohttp.ClientError) and e.status in [502, 504]:breakawait asyncio.sleep(3)raise Exception("Max retries reached or skipping retries. Unable to make the request.")async def CreaListaInput(input_data):
main.py+7-6