Spaces:
Sleeping
Sleeping
Update main.py
Browse files39 unmodified lines4041424344454629 unmodified lines767778798081828383 unmodified lines16716816916716816917017117217317417517617717817917017117287 unmodified lines2602612622732632642654 unmodified lines27027127228427327427539 unmodified lines NumeroGenerazioni: int = 1 StringaSplit: str = '********' NumeroCaratteriSplitInstruction: int = 30000 EliminaRisposteNonPertinenti: bool = False
class InputDataAsync(InputData): test: str = ''29 unmodified lines input_data.asincrono = False result_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data)) LoggaTesto("RISPOSTA ASINCRONA FINALE", {"response": result_data}) if input_data.EliminaRisposteNonPertinenti and "response" in result_data and "NOTFOUND" in result_data["response"]: del result_data["response"] return {"response": result_data} def generate_input_text(input_data):83 unmodified lines await asyncio.sleep(1) raise Exception("Max retries reached or skipping retries. Unable to make the request.")
async def make_request_old(session, token, data, url): headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token } async with session.post(url, headers=headers, json=data) as response: try: result_data = await response.json() except aiohttp.ContentTypeError: result_data = await response.text() return result_data
async def CreaListaInput(input_data): if input_data.instruction.startswith("http"): try:87 unmodified lines ListaInput.append(data) return ListaInput
async def GeneraTestoAsync(url, input_data): token = os.getenv('TOKEN') async with aiohttp.ClientSession() as session:4 unmodified lines tasks.extend([make_request(session, token, data, url) for _ in range(input_data.NumeroGenerazioni)]) return await asyncio.gather(*tasks)
#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------style_image = {main.py+3-15