MatteoScript commited on
Commit
527b418
·
verified ·
1 Parent(s): aef2500

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -2
main.py CHANGED
@@ -325,11 +325,22 @@ async def GeneraTestoAsync(url, input_data):
325
  ListaInput = await CreaListaInput(input_data)
326
  for data in ListaInput:
327
  LoggaTesto("RICHIESTA ASINCRONA", data)
328
- tasks.extend([make_request(session, token, data, url, index, semaphore) for index in range(input_data.NumeroGenerazioni)])
 
329
  await asyncio.sleep(0.1)
330
  return await asyncio.gather(*tasks)
331
 
332
-
 
 
 
 
 
 
 
 
 
 
333
  #--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
334
  style_image = {
335
  "PROFESSIONAL-PHOTO": {
 
325
  ListaInput = await CreaListaInput(input_data)
326
  for data in ListaInput:
327
  LoggaTesto("RICHIESTA ASINCRONA", data)
328
+ #tasks.extend([make_request(session, token, data, url, index, semaphore) for index in range(input_data.NumeroGenerazioni)])
329
+ tasks.extend([generate_text_internal(data) for _ in range(input_data.NumeroGenerazioni)])
330
  await asyncio.sleep(0.1)
331
  return await asyncio.gather(*tasks)
332
 
333
+ async def generate_text_internal(data):
334
+ temperature = data.temperature
335
+ max_new_tokens = data.max_new_tokens
336
+ top_p = data.top_p
337
+ repetition_penalty = data.repetition_penalty
338
+ input_text = generate_input_text(data)
339
+ max_new_tokens = min(max_new_tokens, 29500 - len(input_text))
340
+ history = []
341
+ generated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)
342
+ return generated_response
343
+
344
  #--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
345
  style_image = {
346
  "PROFESSIONAL-PHOTO": {