Spaces:
Runtime error
Runtime error
wiki urls
Browse files
rag.py
CHANGED
@@ -130,7 +130,13 @@ class RAG:
|
|
130 |
response = chat_completion.choices[0].message.content
|
131 |
|
132 |
return response
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
def beautiful_context(self, docs):
|
136 |
|
@@ -142,7 +148,7 @@ class RAG:
|
|
142 |
text_context += doc[0].page_content
|
143 |
full_context += doc[0].page_content + "\n"
|
144 |
full_context += doc[0].metadata["url"] + "\n\n"
|
145 |
-
source_context.append(doc[0].metadata["
|
146 |
|
147 |
return text_context, full_context, source_context
|
148 |
|
|
|
130 |
response = chat_completion.choices[0].message.content
|
131 |
|
132 |
return response
|
133 |
+
|
134 |
+
def get_wiki_url(self, title):
|
135 |
+
base_url = "https://ca.wikipedia.org/wiki/"
|
136 |
+
|
137 |
+
formatted_title = title.replace(" ", "_")
|
138 |
+
|
139 |
+
return base_url + formatted_title
|
140 |
|
141 |
def beautiful_context(self, docs):
|
142 |
|
|
|
148 |
text_context += doc[0].page_content
|
149 |
full_context += doc[0].page_content + "\n"
|
150 |
full_context += doc[0].metadata["url"] + "\n\n"
|
151 |
+
source_context.append(self.get_wiki_url(doc[0].metadata["title"]))
|
152 |
|
153 |
return text_context, full_context, source_context
|
154 |
|