Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,7 +59,23 @@ if st.button('Consultar') and query:
|
|
| 59 |
retrieved_chunks = [chunks[i] for i in I[0]]
|
| 60 |
context = "\n".join(retrieved_chunks)
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
retrieved_chunks = [chunks[i] for i in I[0]]
|
| 60 |
context = "\n".join(retrieved_chunks)
|
| 61 |
|
| 62 |
+
# Si no hi ha context rellevant
|
| 63 |
+
if not context.strip():
|
| 64 |
+
st.warning("No s'ha trobat informació rellevant als documents.")
|
| 65 |
+
else:
|
| 66 |
+
prompt = f"""
|
| 67 |
+
Exemple:
|
| 68 |
+
Pregunta: Quins impostos s'han de pagar?
|
| 69 |
+
Resposta: Els impostos són ITP, AJD i IVA segons el tipus d'operació.
|
| 70 |
+
|
| 71 |
+
Instruccions: Respon en la mateixa llengua de la pregunta basant-te només en el context següent.
|
| 72 |
+
Si no trobes informació al context, indica-ho clarament.
|
| 73 |
+
|
| 74 |
+
Context:
|
| 75 |
+
{context}
|
| 76 |
+
|
| 77 |
+
Pregunta: {query}
|
| 78 |
+
Resposta:
|
| 79 |
+
"""
|
| 80 |
+
response = qa_pipeline(prompt, max_length=512)[0]['generated_text']
|
| 81 |
+
st.write('Resposta IA:')
|