Spaces:
Runtime error
Runtime error
Update main.py
Browse files156 unmodified lines157158159160161162163164165166167111 unmodified lines279280281282283284285156 unmodified linesresult_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data))return {"response": result_data}async def make_request(session, token, data, url, max_retries=3):headers = {'Content-Type': 'application/json','Authorization': 'Bearer ' + token}for _ in range(max_retries):try:async with session.post(url, headers=headers, json=data) as response:111 unmodified linesListaInput = await CreaListaInput(input_data)for data in ListaInput:LoggaTesto("RICHIESTA ASINCRONA", data)tasks.extend([make_request(session, token, data, url) for _ in range(input_data.NumeroGenerazioni)])return await asyncio.gather(*tasks)156 unmodified lines157158159160161162163164165166167168169170171172173111 unmodified lines285286287288289290291156 unmodified linesresult_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data))return {"response": result_data}async def make_request(session, token, data, url, max_retries=3, index):headers = {'Content-Type': 'application/json','Authorization': 'Bearer ' + token}if index % 3 == 1:data.max_new_tokens = data.max_new_tokenselif index % 3 == 2:data.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:111 unmodified linesListaInput = await CreaListaInput(input_data)for data in ListaInput:LoggaTesto("RICHIESTA ASINCRONA", data)tasks.extend([make_request(session, token, data, url, index+1) for _ in range(input_data.NumeroGenerazioni)])return await asyncio.gather(*tasks)
main.py+8-2