Spaces:
Running
Running
Update query.py
Browse files
query.py
CHANGED
@@ -102,9 +102,10 @@ class VectaraQuery():
|
|
102 |
doc_num = responses[response_num-1]['documentIndex']
|
103 |
metadata = {item['name']: item['value'] for item in docs[doc_num]['metadata']}
|
104 |
text = extract_between_tags(responses[response_num-1]['text'], start_tag, end_tag)
|
105 |
-
url
|
106 |
-
|
107 |
-
refs
|
|
|
108 |
|
109 |
# replace references with markdown links
|
110 |
refs_dict = {url:(inx+1) for inx,url in enumerate(refs)}
|
@@ -118,5 +119,4 @@ class VectaraQuery():
|
|
118 |
citation_inx = refs_dict[url]
|
119 |
summary = summary[:start] + f'[\[{citation_inx}\]]({url})' + summary[end:]
|
120 |
|
121 |
-
return summary
|
122 |
-
|
|
|
102 |
doc_num = responses[response_num-1]['documentIndex']
|
103 |
metadata = {item['name']: item['value'] for item in docs[doc_num]['metadata']}
|
104 |
text = extract_between_tags(responses[response_num-1]['text'], start_tag, end_tag)
|
105 |
+
if 'url' in metadata.keys():
|
106 |
+
url = f"{metadata['url']}#:~:text={quote(text)}"
|
107 |
+
if url not in refs:
|
108 |
+
refs.append(url)
|
109 |
|
110 |
# replace references with markdown links
|
111 |
refs_dict = {url:(inx+1) for inx,url in enumerate(refs)}
|
|
|
119 |
citation_inx = refs_dict[url]
|
120 |
summary = summary[:start] + f'[\[{citation_inx}\]]({url})' + summary[end:]
|
121 |
|
122 |
+
return summary
|
|