Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -36,7 +36,7 @@ class InputData(BaseModel):
|
|
36 |
max_new_tokens: int = 2000
|
37 |
top_p: float = 0.95
|
38 |
repetition_penalty: float = 1.0
|
39 |
-
|
40 |
NumeroGenerazioni: int = 1
|
41 |
StringaSplit: str = '********'
|
42 |
NumeroCaratteriSplitInstruction: int = 30000
|
@@ -56,7 +56,7 @@ def LoggaTesto(log_type, text):
|
|
56 |
@app.post("/Genera")
|
57 |
def generate_text(request: Request, input_data: InputData):
|
58 |
LoggaTesto("INPUT", input_data.input)
|
59 |
-
if not input_data.
|
60 |
temperature = input_data.temperature
|
61 |
max_new_tokens = input_data.max_new_tokens
|
62 |
top_p = input_data.top_p
|
@@ -68,7 +68,7 @@ def generate_text(request: Request, input_data: InputData):
|
|
68 |
LoggaTesto("RISPOSTA SINCRONA", generated_response)
|
69 |
return {"response": generated_response}
|
70 |
else:
|
71 |
-
input_data.
|
72 |
result_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data))
|
73 |
LoggaTesto("RISPOSTA ASINCRONA FINALE", result_data)
|
74 |
return {"response": result_data}
|
|
|
36 |
max_new_tokens: int = 2000
|
37 |
top_p: float = 0.95
|
38 |
repetition_penalty: float = 1.0
|
39 |
+
asincrono: bool = False
|
40 |
NumeroGenerazioni: int = 1
|
41 |
StringaSplit: str = '********'
|
42 |
NumeroCaratteriSplitInstruction: int = 30000
|
|
|
56 |
@app.post("/Genera")
|
57 |
def generate_text(request: Request, input_data: InputData):
|
58 |
LoggaTesto("INPUT", input_data.input)
|
59 |
+
if not input_data.asincrono:
|
60 |
temperature = input_data.temperature
|
61 |
max_new_tokens = input_data.max_new_tokens
|
62 |
top_p = input_data.top_p
|
|
|
68 |
LoggaTesto("RISPOSTA SINCRONA", generated_response)
|
69 |
return {"response": generated_response}
|
70 |
else:
|
71 |
+
input_data.asincrono = False
|
72 |
result_data = asyncio.run(GeneraTestoAsync("https://matteoscript-fastapi.hf.space/Genera", input_data))
|
73 |
LoggaTesto("RISPOSTA ASINCRONA FINALE", result_data)
|
74 |
return {"response": result_data}
|