Spaces:
Build error
Build error
Update main.py
Browse files39 unmodified lines40414243444529 unmodified lines75767778798083 unmodified lines16416516616716816917017117217317417517617717817918018118287 unmodified lines2702712722732742752764 unmodified lines28128228328428528628739 unmodified linesNumeroGenerazioni: int = 1StringaSplit: str = '********'NumeroCaratteriSplitInstruction: int = 30000class InputDataAsync(InputData):test: str = ''29 unmodified linesinput_data.asincrono = Falseresult_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data))LoggaTesto("RISPOSTA ASINCRONA FINALE", {"response": result_data})return {"response": result_data}def generate_input_text(input_data):83 unmodified linesawait 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_dataasync def CreaListaInput(input_data):if input_data.instruction.startswith("http"):try:87 unmodified linesListaInput.append(data)return ListaInputasync def GeneraTestoAsync(url, input_data):token = os.getenv('TOKEN')async with aiohttp.ClientSession() as session:4 unmodified linestasks.extend([make_request(session, token, data, url) for _ in range(input_data.NumeroGenerazioni)])return await asyncio.gather(*tasks)#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------style_image = {39 unmodified lines4041424344454629 unmodified lines767778798081828383 unmodified lines16716816917017117287 unmodified lines2602612622632642654 unmodified lines27027127227327427539 unmodified linesNumeroGenerazioni: int = 1StringaSplit: str = '********'NumeroCaratteriSplitInstruction: int = 30000EliminaRisposteNonPertinenti: bool = Falseclass InputDataAsync(InputData):test: str = ''29 unmodified linesinput_data.asincrono = Falseresult_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 linesawait asyncio.sleep(1)raise Exception("Max retries reached or skipping retries. Unable to make the request.")async def CreaListaInput(input_data):if input_data.instruction.startswith("http"):try:87 unmodified linesListaInput.append(data)return ListaInputasync def GeneraTestoAsync(url, input_data):token = os.getenv('TOKEN')async with aiohttp.ClientSession() as session:4 unmodified linestasks.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