Spaces:
Build error
Build error
Update main.py
Browse files48 unmodified lines4950515253545556574 unmodified lines6263646566676882 unmodified lines15115215315415515615715848 unmodified linesinput: str = ''api_name: str = "/chat"def LoggaTesto(log_type, data):formatted_data = json.dumps(data, indent=2)print(f"\n{datetime.now()}: ---------------------------------------------------------------| {log_type} |-------------------------------------------------------------------\n{formatted_data}")#--------------------------------------------------- Generazione TESTO ------------------------------------------------------@app.post("/Genera")4 unmodified linestop_p = input_data.top_prepetition_penalty = input_data.repetition_penaltyinput_text = generate_input_text(input_data)LoggaTesto("RICHIESTA SINCRONA", input_text)max_new_tokens = min(max_new_tokens, 29500 - len(input_text))history = []generated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)82 unmodified linestry:result_data = await response.json()except aiohttp.ContentTypeError:result_data = await response.text()print(result_data)return result_dataexcept (asyncio.TimeoutError, aiohttp.ClientError, requests.exceptions.HTTPError) as e:LoggaTesto("ERRORE ASYNC", {e})48 unmodified lines4950515253545556575859604 unmodified lines6566676869707182 unmodified lines15415515615715815916048 unmodified linesinput: str = ''api_name: str = "/chat"def LoggaTesto(log_type, data, serializza=True):if serializza:formatted_data = json.dumps(data, indent=2)else:formatted_data = dataprint(f"\n{datetime.now()}: ---------------------------------------------------------------| {log_type} |--------------------------------------------------------------\n{formatted_data}")#--------------------------------------------------- Generazione TESTO ------------------------------------------------------@app.post("/Genera")4 unmodified linestop_p = input_data.top_prepetition_penalty = input_data.repetition_penaltyinput_text = generate_input_text(input_data)LoggaTesto("RICHIESTA SINCRONA", input_text, False)max_new_tokens = min(max_new_tokens, 29500 - len(input_text))history = []generated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)82 unmodified linestry: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})
main.py+8-6