Spaces:
Sleeping
Sleeping
Commit
·
3ac0ce6
1
Parent(s):
e75758c
removed prompt for the llm to add the punkts of the document + added section_id to html sources
Browse files
utils.py
CHANGED
|
@@ -93,11 +93,14 @@ def generate_sources_html(nodes, chunks_df=None):
|
|
| 93 |
metadata = node.metadata if hasattr(node, 'metadata') else {}
|
| 94 |
doc_type = metadata.get('type', 'text')
|
| 95 |
doc_id = metadata.get('document_id', 'unknown')
|
|
|
|
| 96 |
|
| 97 |
html += f"<div style='margin-bottom: 15px; padding: 15px; border: 1px solid #4a5568; border-radius: 8px; background-color: #1a202c;'>"
|
| 98 |
|
| 99 |
if doc_type == 'text':
|
| 100 |
html += f"<h4 style='margin: 0 0 10px 0; color: #63b3ed;'>📄 {doc_id}</h4>"
|
|
|
|
|
|
|
| 101 |
elif doc_type == 'table':
|
| 102 |
table_num = metadata.get('table_number', 'unknown')
|
| 103 |
if table_num and table_num != 'unknown':
|
|
@@ -150,9 +153,7 @@ def answer_question(question, query_engine, reranker, current_model, chunks_df=N
|
|
| 150 |
{formatted_context}
|
| 151 |
|
| 152 |
Вопрос пользователя: {question}
|
| 153 |
-
|
| 154 |
-
Инструкции: Отвечай строго на основе предоставленного контекста. Обязательно указывай источники в формате "по пункту X документа Y" или "согласно разделу X документа Y". Если информация из нескольких источников, перечисли их все.
|
| 155 |
-
"""
|
| 156 |
|
| 157 |
log_message(f"Отправляю запрос в LLM с {len(reranked_nodes)} узлами")
|
| 158 |
response = query_engine.query(enhanced_question)
|
|
|
|
| 93 |
metadata = node.metadata if hasattr(node, 'metadata') else {}
|
| 94 |
doc_type = metadata.get('type', 'text')
|
| 95 |
doc_id = metadata.get('document_id', 'unknown')
|
| 96 |
+
section_id = metadata.get('section_id', '')
|
| 97 |
|
| 98 |
html += f"<div style='margin-bottom: 15px; padding: 15px; border: 1px solid #4a5568; border-radius: 8px; background-color: #1a202c;'>"
|
| 99 |
|
| 100 |
if doc_type == 'text':
|
| 101 |
html += f"<h4 style='margin: 0 0 10px 0; color: #63b3ed;'>📄 {doc_id}</h4>"
|
| 102 |
+
html += f"<h4 style='margin: 0 0 10px 0; color: #63b3ed;'>📌 {section_id}</h4>"
|
| 103 |
+
|
| 104 |
elif doc_type == 'table':
|
| 105 |
table_num = metadata.get('table_number', 'unknown')
|
| 106 |
if table_num and table_num != 'unknown':
|
|
|
|
| 153 |
{formatted_context}
|
| 154 |
|
| 155 |
Вопрос пользователя: {question}
|
| 156 |
+
Ответь на вопрос, используя только предоставленный контекст. Если ответ не найден в контексте, скажи "Информация не найдена в базе данных."""
|
|
|
|
|
|
|
| 157 |
|
| 158 |
log_message(f"Отправляю запрос в LLM с {len(reranked_nodes)} узлами")
|
| 159 |
response = query_engine.query(enhanced_question)
|