Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,11 +30,11 @@ def riassumi_testo(testo, max_token_riassunto):
|
|
30 |
temperature=0.5, # Imposta la creatività
|
31 |
)
|
32 |
|
33 |
-
# Estrai il riassunto dalla risposta
|
34 |
-
riassunto = risposta
|
35 |
return riassunto
|
36 |
|
37 |
-
except openai.error.
|
38 |
return f"Errore nella richiesta: {e}"
|
39 |
except openai.error.AuthenticationError:
|
40 |
return "Errore di autenticazione: chiave API non valida."
|
@@ -60,3 +60,4 @@ if __name__ == "__main__":
|
|
60 |
|
61 |
|
62 |
|
|
|
|
30 |
temperature=0.5, # Imposta la creatività
|
31 |
)
|
32 |
|
33 |
+
# Estrai il riassunto dalla risposta correttamente
|
34 |
+
riassunto = risposta['choices'][0]['message']['content'] # Correzione dell'accesso
|
35 |
return riassunto
|
36 |
|
37 |
+
except openai.error.InvalidRequestError as e: # Gestisci errore nella richiesta
|
38 |
return f"Errore nella richiesta: {e}"
|
39 |
except openai.error.AuthenticationError:
|
40 |
return "Errore di autenticazione: chiave API non valida."
|
|
|
60 |
|
61 |
|
62 |
|
63 |
+
|