Spaces:
Sleeping
Sleeping
Upload rag_reponse_002.py
Browse files- rag_reponse_002.py +10 -1
rag_reponse_002.py
CHANGED
@@ -112,7 +112,16 @@ def rag_source(docs):
|
|
112 |
print('starting source function!')
|
113 |
source = ""
|
114 |
for i, doc in enumerate(docs):
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
print('source:', source)
|
117 |
return source
|
118 |
|
|
|
112 |
print('starting source function!')
|
113 |
source = ""
|
114 |
for i, doc in enumerate(docs):
|
115 |
+
# Get the sentence or use a fallback if None is returned
|
116 |
+
extracted_sentence = extract_sentence(doc.page_content) or "内容较短,无法提取完整句子"
|
117 |
+
|
118 |
+
source += (f"**【信息来源 {i+1}】** " +
|
119 |
+
extract_document_name(doc.metadata['source']) +
|
120 |
+
',' +
|
121 |
+
f"第{docs[i].metadata['page']+1}页" +
|
122 |
+
',部分内容摘录:' +
|
123 |
+
extracted_sentence +
|
124 |
+
'\n\n')
|
125 |
print('source:', source)
|
126 |
return source
|
127 |
|