Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ load_dotenv()
|
|
| 17 |
|
| 18 |
# Configura il logging
|
| 19 |
logging.basicConfig(
|
| 20 |
-
level=logging.INFO, #
|
| 21 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 22 |
handlers=[logging.FileHandler("app.log"), logging.StreamHandler()]
|
| 23 |
)
|
|
@@ -114,7 +114,7 @@ def extract_ontology(rdf_file: str, output_file: str):
|
|
| 114 |
"classes": classes[:MAX_CLASSES],
|
| 115 |
"properties": properties[:MAX_PROPERTIES],
|
| 116 |
"entities": entities, # Aggiungi le entità
|
| 117 |
-
"full_ontology": g.serialize(format="xml")
|
| 118 |
}
|
| 119 |
|
| 120 |
# Salva il documento in JSON
|
|
@@ -307,11 +307,11 @@ REGOLE STRINGENTI:
|
|
| 307 |
4) Se la domanda è generica (tipo 'Ciao, come stai?'), rispondi breve.
|
| 308 |
5) Se trovi risultati, la risposta finale deve essere la query SPARQL (una sola riga).
|
| 309 |
6) Se non trovi nulla, rispondi con 'Nessuna info.'
|
| 310 |
-
7) Non multiline. Esempio: PREFIX base: <...> SELECT ?x WHERE { ... }.
|
| 311 |
|
| 312 |
Esempio:
|
| 313 |
Utente: Chi ha creato l'opera 'Amore e Psiche'?
|
| 314 |
-
Risposta: PREFIX base: <http://www.semanticweb.org/lucreziamosca/ontologies/progettoMuseo#> SELECT ?creatore WHERE { ?opera base:hasName "Amore e Psiche" . ?opera base:creatoDa ?creatore . }
|
| 315 |
|
| 316 |
FINE REGOLE
|
| 317 |
"""
|
|
|
|
| 17 |
|
| 18 |
# Configura il logging
|
| 19 |
logging.basicConfig(
|
| 20 |
+
level=logging.INFO, # Ridotto da DEBUG per migliorare le prestazioni
|
| 21 |
format="%(asctime)s - %(levelname)s - %(message)s",
|
| 22 |
handlers=[logging.FileHandler("app.log"), logging.StreamHandler()]
|
| 23 |
)
|
|
|
|
| 114 |
"classes": classes[:MAX_CLASSES],
|
| 115 |
"properties": properties[:MAX_PROPERTIES],
|
| 116 |
"entities": entities, # Aggiungi le entità
|
| 117 |
+
"full_ontology": g.serialize(format="xml").decode("utf-8") # Decodifica per ottenere una stringa
|
| 118 |
}
|
| 119 |
|
| 120 |
# Salva il documento in JSON
|
|
|
|
| 307 |
4) Se la domanda è generica (tipo 'Ciao, come stai?'), rispondi breve.
|
| 308 |
5) Se trovi risultati, la risposta finale deve essere la query SPARQL (una sola riga).
|
| 309 |
6) Se non trovi nulla, rispondi con 'Nessuna info.'
|
| 310 |
+
7) Non multiline. Esempio: PREFIX base: <...> SELECT ?x WHERE {{ ... }}.
|
| 311 |
|
| 312 |
Esempio:
|
| 313 |
Utente: Chi ha creato l'opera 'Amore e Psiche'?
|
| 314 |
+
Risposta: PREFIX base: <http://www.semanticweb.org/lucreziamosca/ontologies/progettoMuseo#> SELECT ?creatore WHERE {{ ?opera base:hasName "Amore e Psiche" . ?opera base:creatoDa ?creatore . }}
|
| 315 |
|
| 316 |
FINE REGOLE
|
| 317 |
"""
|