acumplid commited on
Commit
1983ef1
·
1 Parent(s): ad03b9d

Included url on backend response

Browse files
Files changed (1) hide show
  1. rag.py +5 -5
rag.py CHANGED
@@ -59,20 +59,20 @@ class RAG:
59
  text_context = ""
60
 
61
  full_context = ""
62
-
63
  for doc in docs:
64
  text_context += doc[0].page_content
65
  full_context += doc[0].page_content + "\n"
66
  full_context += doc[0].metadata["Títol de la norma"] + "\n\n"
67
  full_context += doc[0].metadata["url"] + "\n\n"
68
-
69
 
70
- return text_context, full_context
71
 
72
  def get_response(self, prompt: str, model_parameters: dict) -> str:
73
 
74
  docs = self.get_context(prompt, model_parameters["NUM_CHUNKS"])
75
- text_context, full_context = self.beautiful_context(docs)
76
 
77
  del model_parameters["NUM_CHUNKS"]
78
 
@@ -81,4 +81,4 @@ class RAG:
81
  if not response:
82
  return self.NO_ANSWER_MESSAGE
83
 
84
- return response, full_context
 
59
  text_context = ""
60
 
61
  full_context = ""
62
+ source_context = []
63
  for doc in docs:
64
  text_context += doc[0].page_content
65
  full_context += doc[0].page_content + "\n"
66
  full_context += doc[0].metadata["Títol de la norma"] + "\n\n"
67
  full_context += doc[0].metadata["url"] + "\n\n"
68
+ source_context.append(doc[0].metadata["url"])
69
 
70
+ return text_context, full_context, source_context
71
 
72
  def get_response(self, prompt: str, model_parameters: dict) -> str:
73
 
74
  docs = self.get_context(prompt, model_parameters["NUM_CHUNKS"])
75
+ text_context, full_context, source = self.beautiful_context(docs)
76
 
77
  del model_parameters["NUM_CHUNKS"]
78
 
 
81
  if not response:
82
  return self.NO_ANSWER_MESSAGE
83
 
84
+ return response, full_context, source