Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -40,7 +40,7 @@ class InputDataAsync(BaseModel):
|
|
40 |
top_p: float = 0.95
|
41 |
repetition_penalty: float = 1.0
|
42 |
NumeroGenerazioni: int = 1
|
43 |
-
StringaSplit: str = ''
|
44 |
|
45 |
class PostSpazio(BaseModel):
|
46 |
nomeSpazio: str
|
@@ -105,15 +105,19 @@ async def make_request(session, token, data, url):
|
|
105 |
|
106 |
async def GeneraTestoAsync(url, input_data):
|
107 |
token = os.getenv('TOKEN')
|
108 |
-
data = {
|
109 |
-
'input': input_data.input,
|
110 |
-
'temperature': input_data.temperature,
|
111 |
-
'max_new_tokens': input_data.max_new_tokens,
|
112 |
-
'top_p': input_data.top_p,
|
113 |
-
'repetition_penalty': input_data.repetition_penalty
|
114 |
-
}
|
115 |
async with aiohttp.ClientSession() as session:
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
return await asyncio.gather(*tasks)
|
118 |
|
119 |
#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
|
|
|
40 |
top_p: float = 0.95
|
41 |
repetition_penalty: float = 1.0
|
42 |
NumeroGenerazioni: int = 1
|
43 |
+
StringaSplit: str = '********'
|
44 |
|
45 |
class PostSpazio(BaseModel):
|
46 |
nomeSpazio: str
|
|
|
105 |
|
106 |
async def GeneraTestoAsync(url, input_data):
|
107 |
token = os.getenv('TOKEN')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
async with aiohttp.ClientSession() as session:
|
109 |
+
input_strings = input_data.input.split(input_data.StringaSplit)
|
110 |
+
tasks = []
|
111 |
+
for input_string in input_strings:
|
112 |
+
data = {
|
113 |
+
'input': input_string.strip(),
|
114 |
+
'temperature': input_data.temperature,
|
115 |
+
'max_new_tokens': input_data.max_new_tokens,
|
116 |
+
'top_p': input_data.top_p,
|
117 |
+
'repetition_penalty': input_data.repetition_penalty
|
118 |
+
}
|
119 |
+
tasks.append(make_request(session, token, data, url) for _ in range(input_data.NumeroGenerazioni))
|
120 |
+
#tasks = [make_request(session, token, data, url) for _ in range(input_data.NumeroGenerazioni)]
|
121 |
return await asyncio.gather(*tasks)
|
122 |
|
123 |
#--------------------------------------------------- Generazione IMMAGINE ------------------------------------------------------
|