Spaces:
Paused
Paused
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -197,8 +197,8 @@ def debug_search_tables(vector_index, search_term="С-25"):
|
|
| 197 |
|
| 198 |
from documents_prep import normalize_text
|
| 199 |
|
| 200 |
-
# MODIFIED: Update answer_question function
|
| 201 |
-
def answer_question(question, query_engine, reranker, current_model, chunks_df=None):
|
| 202 |
# NORMALIZE the question to convert C to С
|
| 203 |
normalized_question = normalize_text(question)
|
| 204 |
|
|
@@ -226,8 +226,9 @@ def answer_question(question, query_engine, reranker, current_model, chunks_df=N
|
|
| 226 |
log_message(f" [{i+1}] {doc_id} - Table {table_num}: {table_title[:50]}")
|
| 227 |
log_message(f"UNIQUE NODES: {len(unique_retrieved)} nodes")
|
| 228 |
|
| 229 |
-
# Simple reranking with NORMALIZED question
|
| 230 |
-
reranked_nodes = rerank_nodes(normalized_question, unique_retrieved, reranker,
|
|
|
|
| 231 |
|
| 232 |
# Direct query without formatting - use normalized question
|
| 233 |
response = query_engine.query(normalized_question)
|
|
@@ -243,7 +244,7 @@ def answer_question(question, query_engine, reranker, current_model, chunks_df=N
|
|
| 243 |
<h3 style='color: #63b3ed; margin-top: 0;'>Ответ (Модель: {current_model}):</h3>
|
| 244 |
<div style='line-height: 1.6; font-size: 16px;'>{response.response}</div>
|
| 245 |
<div style='margin-top: 15px; padding-top: 10px; border-top: 1px solid #4a5568; font-size: 14px; color: #a0aec0;'>
|
| 246 |
-
Время обработки: {processing_time:.2f} секунд
|
| 247 |
</div>
|
| 248 |
</div>"""
|
| 249 |
log_message(f"Model Answer: {response.response}")
|
|
|
|
| 197 |
|
| 198 |
from documents_prep import normalize_text
|
| 199 |
|
| 200 |
+
# MODIFIED: Update answer_question function signature
|
| 201 |
+
def answer_question(question, query_engine, reranker, current_model, chunks_df=None, rerank_top_k=20):
|
| 202 |
# NORMALIZE the question to convert C to С
|
| 203 |
normalized_question = normalize_text(question)
|
| 204 |
|
|
|
|
| 226 |
log_message(f" [{i+1}] {doc_id} - Table {table_num}: {table_title[:50]}")
|
| 227 |
log_message(f"UNIQUE NODES: {len(unique_retrieved)} nodes")
|
| 228 |
|
| 229 |
+
# Simple reranking with NORMALIZED question and PARAMETERIZED top_k
|
| 230 |
+
reranked_nodes = rerank_nodes(normalized_question, unique_retrieved, reranker,
|
| 231 |
+
top_k=rerank_top_k) # NOW PARAMETERIZED
|
| 232 |
|
| 233 |
# Direct query without formatting - use normalized question
|
| 234 |
response = query_engine.query(normalized_question)
|
|
|
|
| 244 |
<h3 style='color: #63b3ed; margin-top: 0;'>Ответ (Модель: {current_model}):</h3>
|
| 245 |
<div style='line-height: 1.6; font-size: 16px;'>{response.response}</div>
|
| 246 |
<div style='margin-top: 15px; padding-top: 10px; border-top: 1px solid #4a5568; font-size: 14px; color: #a0aec0;'>
|
| 247 |
+
Время обработки: {processing_time:.2f} секунд
|
| 248 |
</div>
|
| 249 |
</div>"""
|
| 250 |
log_message(f"Model Answer: {response.response}")
|