Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,24 +200,24 @@ class ManualChatbot:
|
|
| 200 |
)
|
| 201 |
self.vectorstore.persist()
|
| 202 |
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
|
| 222 |
# もしQAチェーンがなければ初期化
|
| 223 |
if not hasattr(self, 'qa_chain') or self.qa_chain is None:
|
|
|
|
| 200 |
)
|
| 201 |
self.vectorstore.persist()
|
| 202 |
|
| 203 |
+
except Exception as e:
|
| 204 |
+
print(f"ベクトルストア作成中にエラー発生: {str(e)}")
|
| 205 |
+
# 既存のchroma_dbディレクトリを削除して再作成する
|
| 206 |
+
import shutil
|
| 207 |
+
if os.path.exists("./chroma_db"):
|
| 208 |
+
shutil.rmtree("./chroma_db")
|
| 209 |
+
os.makedirs("./chroma_db", exist_ok=True)
|
| 210 |
+
# 再度作成を試みる
|
| 211 |
+
self.vectorstore = Chroma.from_documents(
|
| 212 |
+
documents=chunks,
|
| 213 |
+
embedding=embeddings,
|
| 214 |
+
persist_directory="./chroma_db"
|
| 215 |
+
)
|
| 216 |
+
self.vectorstore.persist() else:
|
| 217 |
+
# 既存のベクトルストアに新しいドキュメントを追加
|
| 218 |
+
self.vectorstore.add_documents(chunks)
|
| 219 |
+
# ベクトルストアを保存
|
| 220 |
+
self.vectorstore.persist()
|
| 221 |
|
| 222 |
# もしQAチェーンがなければ初期化
|
| 223 |
if not hasattr(self, 'qa_chain') or self.qa_chain is None:
|