Spaces:
Sleeping
Sleeping
File size: 5,962 Bytes
642c18b |
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
"""
์์คํ
์ค์ ๊ฒ์ฆ ์คํฌ๋ฆฝํธ
์ค์ ์คํ ์ ์ ๋ชจ๋ ๊ตฌ์ฑ ์์๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํฉ๋๋ค.
"""
import sys
from pathlib import Path
import os
# ํ๋ก์ ํธ ๋ฃจํธ๋ฅผ Python ๊ฒฝ๋ก์ ์ถ๊ฐ
project_root = Path(__file__).parent.parent
sys.path.insert(0, str(project_root))
def check_file_structure():
"""ํ์ผ ๊ตฌ์กฐ ํ์ธ"""
print("=" * 80)
print("1๏ธโฃ ํ์ผ ๊ตฌ์กฐ ๊ฒ์ฆ")
print("=" * 80)
required_files = [
"app/main.py",
"app/metacognitive_agent.py",
"app/rag_pipeline.py",
"app/api/routes.py",
"app/api/models.py",
"services/pdf_processor.py",
"services/chunker.py",
"services/embedder.py",
"services/vector_store.py",
"utils/config.py",
"scripts/index_pdfs.py",
"requirements.txt",
".env.example"
]
missing = []
for file in required_files:
filepath = project_root / file
if filepath.exists():
print(f"โ
{file}")
else:
print(f"โ {file} - ๋๋ฝ!")
missing.append(file)
if missing:
print(f"\nโ ๏ธ {len(missing)}๊ฐ ํ์ผ ๋๋ฝ")
return False
else:
print(f"\nโ
๋ชจ๋ ํ์ ํ์ผ ์กด์ฌ ({len(required_files)}๊ฐ)")
return True
def check_env_file():
"""ํ๊ฒฝ ๋ณ์ ํ์ผ ํ์ธ"""
print("\n" + "=" * 80)
print("2๏ธโฃ ํ๊ฒฝ ๋ณ์ ๊ฒ์ฆ")
print("=" * 80)
env_file = project_root / ".env"
env_example = project_root / ".env.example"
if not env_file.exists():
print("โ ๏ธ .env ํ์ผ์ด ์์ต๋๋ค")
print(" cp .env.example .env ๋ฅผ ์คํํ์ธ์")
return False
print("โ
.env ํ์ผ ์กด์ฌ")
# .env ํ์ผ ๋ด์ฉ ํ์ธ
with open(env_file) as f:
content = f.read()
required_keys = [
"ANTHROPIC_API_KEY",
"PDF_SOURCE_PATH",
"CHROMA_PERSIST_DIRECTORY",
"EMBEDDING_MODEL"
]
for key in required_keys:
if key in content:
# ๊ฐ์ด ์ค์ ๋์๋์ง ํ์ธ
for line in content.split('\n'):
if line.startswith(key):
value = line.split('=', 1)[1].strip()
if value and not value.startswith('your_'):
print(f"โ
{key}: ์ค์ ๋จ")
else:
print(f"โ ๏ธ {key}: ๊ฐ ํ์")
else:
print(f"โ {key}: ๋๋ฝ")
return True
def check_code_syntax():
"""Python ์ฝ๋ ๊ตฌ๋ฌธ ๊ฒ์ฆ"""
print("\n" + "=" * 80)
print("3๏ธโฃ Python ์ฝ๋ ๊ตฌ๋ฌธ ๊ฒ์ฆ")
print("=" * 80)
python_files = list(project_root.glob("**/*.py"))
errors = []
for py_file in python_files:
if 'venv' in str(py_file) or '__pycache__' in str(py_file):
continue
try:
with open(py_file) as f:
compile(f.read(), str(py_file), 'exec')
print(f"โ
{py_file.relative_to(project_root)}")
except SyntaxError as e:
print(f"โ {py_file.relative_to(project_root)}: {e}")
errors.append((py_file, e))
if errors:
print(f"\nโ {len(errors)}๊ฐ ํ์ผ์ ๊ตฌ๋ฌธ ์ค๋ฅ")
return False
else:
print(f"\nโ
๋ชจ๋ Python ํ์ผ ๊ตฌ๋ฌธ ์ ์ ({len(python_files)}๊ฐ)")
return True
def check_directories():
"""ํ์ ๋๋ ํ ๋ฆฌ ํ์ธ"""
print("\n" + "=" * 80)
print("4๏ธโฃ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ ๊ฒ์ฆ")
print("=" * 80)
required_dirs = [
"app",
"app/api",
"services",
"utils",
"scripts",
"data"
]
for dir_name in required_dirs:
dir_path = project_root / dir_name
if dir_path.exists() and dir_path.is_dir():
print(f"โ
{dir_name}/")
else:
print(f"โ {dir_name}/ - ๋๋ฝ!")
return False
print(f"\nโ
๋ชจ๋ ๋๋ ํ ๋ฆฌ ์กด์ฌ")
return True
def check_shell_scripts():
"""Shell ์คํฌ๋ฆฝํธ ํ์ธ"""
print("\n" + "=" * 80)
print("5๏ธโฃ Shell ์คํฌ๋ฆฝํธ ๊ฒ์ฆ")
print("=" * 80)
scripts = [
"setup.sh",
"run_indexing.sh",
"run_server.sh",
"upload_to_github.sh"
]
for script in scripts:
script_path = project_root / script
if script_path.exists():
# ์คํ ๊ถํ ํ์ธ
if os.access(script_path, os.X_OK):
print(f"โ
{script} (์คํ ๊ฐ๋ฅ)")
else:
print(f"โ ๏ธ {script} (์คํ ๊ถํ ์์)")
else:
print(f"โ {script} - ๋๋ฝ!")
return True
def main():
"""์ ์ฒด ๊ฒ์ฆ ์คํ"""
print("\n")
print("โ" + "=" * 78 + "โ")
print("โ" + " " * 20 + "์์คํ
์ค์ ๊ฒ์ฆ" + " " * 43 + "โ")
print("โ" + "=" * 78 + "โ")
print()
results = []
results.append(("ํ์ผ ๊ตฌ์กฐ", check_file_structure()))
results.append(("ํ๊ฒฝ ๋ณ์", check_env_file()))
results.append(("์ฝ๋ ๊ตฌ๋ฌธ", check_code_syntax()))
results.append(("๋๋ ํ ๋ฆฌ", check_directories()))
results.append(("Shell ์คํฌ๋ฆฝํธ", check_shell_scripts()))
# ์ต์ข
๊ฒฐ๊ณผ
print("\n" + "=" * 80)
print("๐ ๊ฒ์ฆ ๊ฒฐ๊ณผ")
print("=" * 80)
for name, result in results:
status = "โ
ํต๊ณผ" if result else "โ ์คํจ"
print(f"{name:15} : {status}")
all_passed = all(result for _, result in results)
print("=" * 80)
if all_passed:
print("โ
๋ชจ๋ ๊ฒ์ฆ ํต๊ณผ!")
print("\n๋ค์ ๋จ๊ณ:")
print("1. .env ํ์ผ์ API ํค ์
๋ ฅ")
print("2. ./run_indexing.sh ์คํ (PDF ์ธ๋ฑ์ฑ)")
print("3. ./run_server.sh ์คํ (API ์๋ฒ)")
else:
print("โ ์ผ๋ถ ๊ฒ์ฆ ์คํจ")
print("์์ ์ค๋ฅ๋ฅผ ์์ ํ์ธ์.")
print("=" * 80)
if __name__ == "__main__":
main()
|