ankush13r commited on
Commit
e742531
1 Parent(s): a5d9210
Files changed (1) hide show
  1. rag.py +11 -9
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 text_contexvectorstoret, full_context, source_context
74
 
75
  def get_response(self, prompt: str, model_parameters: dict) -> str:
76
-
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
 
 
 
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)