Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,13 +16,28 @@ from llama_index.core.node_parser import SentenceSplitter
|
|
16 |
|
17 |
max_seq_length = 512 # Choose any! We auto support RoPE Scaling internally!
|
18 |
|
19 |
-
prompt = """Responde a preguntas de forma clara, amable, concisa y solamente en el lenguaje español, sobre el libro Ñande Ypykuéra.
|
20 |
-
Contexto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
-------------------------
|
|
|
22 |
{}
|
23 |
-------------------------
|
|
|
24 |
### Pregunta:
|
25 |
{}
|
|
|
|
|
|
|
26 |
### Respuesta:
|
27 |
{}"""
|
28 |
|
@@ -49,6 +64,9 @@ print(os.getcwd())
|
|
49 |
|
50 |
# if os.path.exists(DOC_PATH):
|
51 |
RAG = RAGPretrainedModel.from_index(DOC_PATH, n_gpu=None)
|
|
|
|
|
|
|
52 |
# else:
|
53 |
# RAG = RAGPretrainedModel.from_pretrained("AdrienB134/ColBERTv2.0-spanish-mmarcoES")
|
54 |
# my_documents = list_nodes
|
@@ -73,7 +91,7 @@ def reformat_rag(results_rag):
|
|
73 |
|
74 |
def chat_stream_completion(message, history):
|
75 |
|
76 |
-
context = reformat_rag(RAG.search(message, DOC_PATH, k=2))
|
77 |
context = " \n ".join(context)
|
78 |
|
79 |
full_prompt = prompt.format(context,message,"")
|
|
|
16 |
|
17 |
max_seq_length = 512 # Choose any! We auto support RoPE Scaling internally!
|
18 |
|
19 |
+
# prompt = """Responde a preguntas de forma clara, amable, concisa y solamente en el lenguaje español, sobre el libro Ñande Ypykuéra.
|
20 |
+
# Contexto
|
21 |
+
# -------------------------
|
22 |
+
# {}
|
23 |
+
# -------------------------
|
24 |
+
# ### Pregunta:
|
25 |
+
# {}
|
26 |
+
# ### Respuesta:
|
27 |
+
# {}"""
|
28 |
+
|
29 |
+
prompt = """Responde a preguntas de forma clara, amable, concisa y solamente en el lenguaje español.
|
30 |
+
|
31 |
-------------------------
|
32 |
+
Contexto:
|
33 |
{}
|
34 |
-------------------------
|
35 |
+
|
36 |
### Pregunta:
|
37 |
{}
|
38 |
+
|
39 |
+
- Debes utilizar el contexto para responder la pregunta.
|
40 |
+
|
41 |
### Respuesta:
|
42 |
{}"""
|
43 |
|
|
|
64 |
|
65 |
# if os.path.exists(DOC_PATH):
|
66 |
RAG = RAGPretrainedModel.from_index(DOC_PATH, n_gpu=None)
|
67 |
+
|
68 |
+
print(RAG)
|
69 |
+
|
70 |
# else:
|
71 |
# RAG = RAGPretrainedModel.from_pretrained("AdrienB134/ColBERTv2.0-spanish-mmarcoES")
|
72 |
# my_documents = list_nodes
|
|
|
91 |
|
92 |
def chat_stream_completion(message, history):
|
93 |
|
94 |
+
context = ""#reformat_rag(RAG.search(message, DOC_PATH, k=2))
|
95 |
context = " \n ".join(context)
|
96 |
|
97 |
full_prompt = prompt.format(context,message,"")
|