kimrang commited on
Commit
1cf3263
·
verified ·
1 Parent(s): 93bd624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -9
app.py CHANGED
@@ -26,24 +26,40 @@ def load_vectorstore():
26
  model_name="sentence-transformers/all-MiniLM-L6-v2"
27
  )
28
 
29
- # 현재 작업 디렉토리 확인
30
- print(f"현재 디렉토리: {os.getcwd()}")
31
- print(f"vectorstore 폴더 존재 여부: {os.path.exists('vectorstore')}")
32
 
33
- # vectorstore 폴더 내 파일들 확인
34
- if os.path.exists('vectorstore'):
35
- files = os.listdir('vectorstore')
36
- print(f"vectorstore 폴더 내 파일들: {files}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  vectorstore = FAISS.load_local(
39
- "./vectorstore",
40
  embeddings,
41
  allow_dangerous_deserialization=True
42
  )
43
  print("✅ 벡터스토어 로드 완료")
 
44
  except Exception as e:
45
  print(f"❌ 벡터스토어 로드 실패: {e}")
46
- print(f"❌ 에러 타입: {type(e).__name__}")
 
47
  vectorstore = None
48
 
49
  return vectorstore
 
26
  model_name="sentence-transformers/all-MiniLM-L6-v2"
27
  )
28
 
29
+ # 절대 경로로 확인
30
+ vectorstore_path = os.path.join(os.getcwd(), "vectorstore")
31
+ print(f"벡터스토어 경로: {vectorstore_path}")
32
 
33
+ # 필수 파일들 확인
34
+ required_files = ["index.faiss", "index.pkl"]
35
+ missing_files = []
36
+
37
+ if os.path.exists(vectorstore_path):
38
+ existing_files = os.listdir(vectorstore_path)
39
+ print(f"존재하는 파일들: {existing_files}")
40
+
41
+ for file in required_files:
42
+ if file not in existing_files:
43
+ missing_files.append(file)
44
+
45
+ if missing_files:
46
+ print(f"❌ 누락된 파일들: {missing_files}")
47
+ return None
48
+ else:
49
+ print("❌ vectorstore 폴더가 존재하지 않습니다")
50
+ return None
51
 
52
  vectorstore = FAISS.load_local(
53
+ vectorstore_path,
54
  embeddings,
55
  allow_dangerous_deserialization=True
56
  )
57
  print("✅ 벡터스토어 로드 완료")
58
+
59
  except Exception as e:
60
  print(f"❌ 벡터스토어 로드 실패: {e}")
61
+ import traceback
62
+ traceback.print_exc()
63
  vectorstore = None
64
 
65
  return vectorstore