Spaces:
Paused
Paused
File size: 5,758 Bytes
4aa05c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# test_basic_integration.py - ๊ธฐ๋ณธ ํตํฉ ํ
์คํธ (PyTorch ์์ด)
import os
import sys
import time
from datetime import datetime
def test_basic_imports():
"""๊ธฐ๋ณธ ๋ชจ๋ import ํ
์คํธ"""
print("[IMPORT] ๊ธฐ๋ณธ ๋ชจ๋ import ํ
์คํธ...")
results = {}
# 1. LLM ํ๋ก์ธ์์ ๊ณ์ฐ ์์ง ๋ถ๋ถ๋ง ํ
์คํธ
try:
from llm_processor import TaxRuleEngine
engine = TaxRuleEngine()
# ๊ฐ๋จํ ๊ณ์ฐ ํ
์คํธ
test_property = {
'acquisition_value': 1000000000, # 10์ต์
'location': '์์ธํน๋ณ์ ๊ฐ๋จ๊ตฌ',
'housing_list': [{'id': 1}, {'id': 2}] # ๊ธฐ์กด 2์ฃผํ
}
result = engine.calculate_comprehensive_tax(test_property)
if result and result['tax_amount'] > 0:
print(f"[OK] ์ทจ๋์ธ ๊ณ์ฐ ์์ง: {result['tax_amount']:,}์")
results['tax_engine'] = True
else:
print("[ERROR] ์ทจ๋์ธ ๊ณ์ฐ ์คํจ")
results['tax_engine'] = False
except Exception as e:
print(f"[ERROR] ์ทจ๋์ธ ๊ณ์ฐ ์์ง import ์คํจ: {e}")
results['tax_engine'] = False
# 2. ๊ธฐ๋ณธ ํ์ผ๋ค ์กด์ฌ ํ์ธ
required_files = [
'llm_processor.py',
'rag_system.py',
'app.py',
'config.py',
'law_fetcher.py'
]
missing_files = []
for file in required_files:
if not os.path.exists(file):
missing_files.append(file)
if not missing_files:
print("[OK] ๋ชจ๋ ํ์ ํ์ผ ์กด์ฌ")
results['files'] = True
else:
print(f"[ERROR] ๋๋ฝ๋ ํ์ผ: {missing_files}")
results['files'] = False
# 3. ์ค์ ํ์ผ ๋ก๋ ํ
์คํธ
try:
from config import RAG_CONFIG
if RAG_CONFIG and 'embedding_models' in RAG_CONFIG:
print("[OK] ์ค์ ํ์ผ ๋ก๋ ์๋ฃ")
results['config'] = True
else:
print("[ERROR] ์ค์ ํ์ผ ๋ด์ฉ ๋ถ์์ ")
results['config'] = False
except Exception as e:
print(f"[ERROR] ์ค์ ํ์ผ ๋ก๋ ์คํจ: {e}")
results['config'] = False
# 4. LLM ํ๋ก์ธ์์ ์ ๋ณด ์ถ์ถ ๊ธฐ๋ฅ ํ
์คํธ
try:
from llm_processor import LLMProcessor
processor = LLMProcessor()
# ๋ชจ๋ธ ๋ก๋ฉ ์์ด ์ ๋ณด ์ถ์ถ๋ง ํ
์คํธ
test_input = "๊ฐ๋จ๊ตฌ์์ 10์ต์ ์ํํธ๋ฅผ ๊ตฌ๋งคํ๋๋ฐ ๊ธฐ์กด์ 2์ฃผํ ๋ณด์ "
property_info = processor.extract_property_info(test_input)
if (property_info.get('acquisition_value') == 1000000000 and
'๊ฐ๋จ๊ตฌ' in property_info.get('location', '') and
len(property_info.get('housing_list', [])) == 2):
print("[OK] ์ ๋ณด ์ถ์ถ ๊ธฐ๋ฅ ์ ์")
results['extraction'] = True
else:
print(f"[PARTIAL] ์ ๋ณด ์ถ์ถ ๋ถ๋ถ์ ์ฑ๊ณต: {property_info}")
results['extraction'] = True # ๋ถ๋ถ์ ์ด๋ผ๋ ์๋ํ๋ฉด OK
except Exception as e:
print(f"[ERROR] ์ ๋ณด ์ถ์ถ ํ
์คํธ ์คํจ: {e}")
results['extraction'] = False
return results
def test_web_integration():
"""์น ํตํฉ ํ
์คํธ (Flask ์ฑ ๊ตฌ์กฐ ํ์ธ)"""
print("[WEB] ์น ํตํฉ ๊ตฌ์กฐ ํ
์คํธ...")
try:
# app.py์ ๊ธฐ๋ณธ ๊ตฌ์กฐ ํ์ธ
with open('app.py', 'r', encoding='utf-8') as f:
app_content = f.read()
required_patterns = [
'Flask',
'/api/web/chat',
'search_tax_law'
]
missing_patterns = []
for pattern in required_patterns:
if pattern not in app_content:
missing_patterns.append(pattern)
if not missing_patterns:
print("[OK] ์น ์ฑ ๊ตฌ์กฐ ํ์ธ ์๋ฃ")
return True
else:
print(f"[ERROR] ์น ์ฑ์์ ๋๋ฝ๋ ํจํด: {missing_patterns}")
return False
except Exception as e:
print(f"[ERROR] ์น ํตํฉ ํ
์คํธ ์คํจ: {e}")
return False
def main():
"""๋ฉ์ธ ํ
์คํธ"""
print("[MAIN] ๊ธฐ๋ณธ ํตํฉ ํ
์คํธ ์์ (PyTorch ์์ด)")
print("=" * 60)
print(f"[TIME] ํ
์คํธ ์๊ฐ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("=" * 60)
# 1. ๊ธฐ๋ณธ import ํ
์คํธ
print("\n[1] ๊ธฐ๋ณธ ๋ชจ๋ ํ
์คํธ")
print("-" * 30)
import_results = test_basic_imports()
# 2. ์น ํตํฉ ํ
์คํธ
print("\n[2] ์น ํตํฉ ํ
์คํธ")
print("-" * 30)
web_result = test_web_integration()
# 3. ๊ฒฐ๊ณผ ์ ๋ฆฌ
print("\n" + "=" * 60)
print("[SUMMARY] ํ
์คํธ ๊ฒฐ๊ณผ")
print("=" * 60)
all_results = {**import_results, 'web_integration': web_result}
total_tests = len(all_results)
passed_tests = sum(all_results.values())
print(f"[PASS] ํต๊ณผ: {passed_tests}/{total_tests}")
print(f"[FAIL] ์คํจ: {total_tests - passed_tests}/{total_tests}")
for test_name, result in all_results.items():
status = "PASS" if result else "FAIL"
print(f" {test_name}: {status}")
if passed_tests >= total_tests * 0.7: # 70% ์ด์ ํต๊ณผํ๋ฉด ์ฑ๊ณต
print(f"\n[SUCCESS] ๊ธฐ๋ณธ ํตํฉ ํ
์คํธ ํต๊ณผ! ({passed_tests}/{total_tests})")
print("[INFO] HuggingFace Spaces์์๋ GPU ํ๊ฒฝ์์ ์ ์ ์๋ํ ์์ ์
๋๋ค.")
return True
else:
print(f"\n[WARNING] ๊ธฐ๋ณธ ํ
์คํธ์์ ๋ฌธ์ ๋ฐ๊ฒฌ. ์์ ์ด ํ์ํฉ๋๋ค.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1) |