Spaces:
Sleeping
Sleeping
fix bug
Browse files
rag.py
CHANGED
@@ -70,18 +70,20 @@ class RAG:
|
|
70 |
full_context += doc[0].metadata["url"] + "\n\n"
|
71 |
source_context.append(doc[0].metadata["url"])
|
72 |
|
73 |
-
return
|
74 |
|
75 |
def get_response(self, prompt: str, model_parameters: dict) -> str:
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
|
|
|
|
|
70 |
full_context += doc[0].metadata["url"] + "\n\n"
|
71 |
source_context.append(doc[0].metadata["url"])
|
72 |
|
73 |
+
return text_context, full_context, source_context
|
74 |
|
75 |
def get_response(self, prompt: str, model_parameters: dict) -> str:
|
76 |
+
try:
|
77 |
+
docs = self.get_context(prompt, model_parameters["NUM_CHUNKS"])
|
78 |
+
text_context, full_context, source = self.beautiful_context(docs)
|
79 |
|
80 |
+
del model_parameters["NUM_CHUNKS"]
|
81 |
|
82 |
+
response = self.predict(prompt, text_context, model_parameters)
|
83 |
|
84 |
+
if not response:
|
85 |
+
return self.NO_ANSWER_MESSAGE
|
86 |
|
87 |
+
return response, full_context, source
|
88 |
+
except Exception as err:
|
89 |
+
print(err)
|