Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,6 @@ import leximind_prompts
|
|
| 40 |
# --- 전역 변수 ---
|
| 41 |
connected_clients = 0
|
| 42 |
search_document_number = 30
|
| 43 |
-
filters = {"regulation_part": []}
|
| 44 |
|
| 45 |
# --- 경로 설정 ---
|
| 46 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -133,7 +132,6 @@ Search_each_all_mode = True # 기본값을 클라이언트에서 제어 가능
|
|
| 133 |
|
| 134 |
@socketio.on('search_query')
|
| 135 |
def handle_search_query(data):
|
| 136 |
-
global filters
|
| 137 |
global Search_each_all_mode
|
| 138 |
global current_dir
|
| 139 |
|
|
@@ -158,14 +156,6 @@ def handle_search_query(data):
|
|
| 158 |
logger.info("선택된 법규: %s", selected_regulations)
|
| 159 |
logger.info("검색 모드: %s", "각각 검색" if Search_each_all_mode else "통합 검색")
|
| 160 |
|
| 161 |
-
# 법규 타입별로 필터 구분
|
| 162 |
-
filters = {
|
| 163 |
-
"regulation_part": [],
|
| 164 |
-
"regulation_section": [],
|
| 165 |
-
"chapter_section": [],
|
| 166 |
-
"jo": []
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
# 번역 진행 상황 알림
|
| 170 |
emit('search_status', {'status': 'translating', 'message': '질문에 대해 생각 중입니다...'})
|
| 171 |
|
|
@@ -485,20 +475,15 @@ def Gemma3_AI_Translate(query_txt):
|
|
| 485 |
# --- 검색 ---
|
| 486 |
# 검색 함수 수정
|
| 487 |
def search_DB_from_multiple_regions(query, selected_regions, region_rag_objects, custom_filters=None, failsafe_mode=True):
|
| 488 |
-
global filters
|
| 489 |
-
|
| 490 |
if not selected_regions:
|
| 491 |
selected_regions = list(region_rag_objects.keys())
|
| 492 |
|
| 493 |
print(f"Translated Query : {query}")
|
| 494 |
-
|
| 495 |
-
# 커스텀 필터가 제공된 경우 사용
|
| 496 |
-
search_filters = custom_filters if custom_filters is not None else filters
|
| 497 |
|
| 498 |
# 필터가 설정되어 있는지 확인
|
| 499 |
-
has_filters = any(
|
| 500 |
|
| 501 |
-
print(f"사용된 검색 필터: {
|
| 502 |
print(f"필터 사용 여부: {has_filters}")
|
| 503 |
|
| 504 |
combined_results = []
|
|
@@ -519,7 +504,7 @@ def search_DB_from_multiple_regions(query, selected_regions, region_rag_objects,
|
|
| 519 |
vectorstore=vectorstore,
|
| 520 |
query=query,
|
| 521 |
k=search_document_number,
|
| 522 |
-
metadata_filter=
|
| 523 |
sqlite_conn=sqlite_conn,
|
| 524 |
failsafe_search=failsafe_mode
|
| 525 |
)
|
|
|
|
| 40 |
# --- 전역 변수 ---
|
| 41 |
connected_clients = 0
|
| 42 |
search_document_number = 30
|
|
|
|
| 43 |
|
| 44 |
# --- 경로 설정 ---
|
| 45 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 132 |
|
| 133 |
@socketio.on('search_query')
|
| 134 |
def handle_search_query(data):
|
|
|
|
| 135 |
global Search_each_all_mode
|
| 136 |
global current_dir
|
| 137 |
|
|
|
|
| 156 |
logger.info("선택된 법규: %s", selected_regulations)
|
| 157 |
logger.info("검색 모드: %s", "각각 검색" if Search_each_all_mode else "통합 검색")
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
# 번역 진행 상황 알림
|
| 160 |
emit('search_status', {'status': 'translating', 'message': '질문에 대해 생각 중입니다...'})
|
| 161 |
|
|
|
|
| 475 |
# --- 검색 ---
|
| 476 |
# 검색 함수 수정
|
| 477 |
def search_DB_from_multiple_regions(query, selected_regions, region_rag_objects, custom_filters=None, failsafe_mode=True):
|
|
|
|
|
|
|
| 478 |
if not selected_regions:
|
| 479 |
selected_regions = list(region_rag_objects.keys())
|
| 480 |
|
| 481 |
print(f"Translated Query : {query}")
|
|
|
|
|
|
|
|
|
|
| 482 |
|
| 483 |
# 필터가 설정되어 있는지 확인
|
| 484 |
+
has_filters = any(custom_filters.get(key, []) for key in custom_filters.keys())
|
| 485 |
|
| 486 |
+
print(f"사용된 검색 필터: {custom_filters}")
|
| 487 |
print(f"필터 사용 여부: {has_filters}")
|
| 488 |
|
| 489 |
combined_results = []
|
|
|
|
| 504 |
vectorstore=vectorstore,
|
| 505 |
query=query,
|
| 506 |
k=search_document_number,
|
| 507 |
+
metadata_filter=custom_filters,
|
| 508 |
sqlite_conn=sqlite_conn,
|
| 509 |
failsafe_search=failsafe_mode
|
| 510 |
)
|