HaRin2806 commited on
Commit
6f6eb6d
·
1 Parent(s): bed7720
Files changed (1) hide show
  1. core/rag_pipeline.py +4 -8
core/rag_pipeline.py CHANGED
@@ -140,7 +140,7 @@ class RAGPipeline:
140
  }
141
 
142
  def _format_contexts(self, contexts):
143
- # Định dạng ngữ cảnh với tên tài liệu thực tế + chunk ID
144
  formatted = []
145
 
146
  for i, context in enumerate(contexts, 1):
@@ -152,7 +152,7 @@ class RAGPipeline:
152
  chapter = metadata.get('chapter', '')
153
  original_title = metadata.get('title', '')
154
 
155
- # Tạo tên tài liệu dựa trên chapter (giống logic trong generate_response)
156
  if 'bai1' in chapter:
157
  document_name = "Bài 1: Dinh dưỡng theo lứa tuổi học sinh"
158
  elif 'bai2' in chapter:
@@ -166,12 +166,8 @@ class RAGPipeline:
166
  else:
167
  document_name = metadata.get('document_title') or "Tài liệu dinh dưỡng"
168
 
169
- # Format: [Tài liệu {tên} - ID: {chunk_id}]
170
- context_str = f"[Tài liệu {document_name} - ID: {chunk_id}]"
171
-
172
- # Thêm thông tin trang nếu có
173
- if metadata.get('pages'):
174
- context_str += f" (Trang {metadata['pages']})"
175
 
176
  # Thêm title của chunk nếu có và có ý nghĩa
177
  if original_title and original_title.strip() and len(original_title.strip()) > 3:
 
140
  }
141
 
142
  def _format_contexts(self, contexts):
143
+ # Định dạng ngữ cảnh với tên tài liệu thực tế + chunk ID
144
  formatted = []
145
 
146
  for i, context in enumerate(contexts, 1):
 
152
  chapter = metadata.get('chapter', '')
153
  original_title = metadata.get('title', '')
154
 
155
+ # Tạo tên tài liệu dựa trên chapter
156
  if 'bai1' in chapter:
157
  document_name = "Bài 1: Dinh dưỡng theo lứa tuổi học sinh"
158
  elif 'bai2' in chapter:
 
166
  else:
167
  document_name = metadata.get('document_title') or "Tài liệu dinh dưỡng"
168
 
169
+ # Format: [{tên bài} - ID: {chunk_id}]
170
+ context_str = f"[{document_name} - ID: {chunk_id}]"
 
 
 
 
171
 
172
  # Thêm title của chunk nếu có và có ý nghĩa
173
  if original_title and original_title.strip() and len(original_title.strip()) > 3: