docker 설정 수정

This commit is contained in:
2025-03-07 19:22:05 +09:00
parent 9118c40c56
commit 309e98f47d
3 changed files with 21 additions and 4 deletions

13
main.py
View File

@@ -84,10 +84,15 @@ def load_and_process_documents(directory_path):
def save_faiss_index(faiss_index, path="faiss_index"):
faiss_index.save_local(path)
print("-------------------------------------------")
print("save_faiss_index")
print("-------------------------------------------")
def load_faiss_index(path="faiss_index"):
embeddings = embedding()
print("-------------------------------------------")
print("load_faiss_index")
print("-------------------------------------------")
return FAISS.load_local(path, embeddings, allow_dangerous_deserialization=True)
@@ -101,6 +106,7 @@ def initialize_processing():
try:
faiss_index = load_faiss_index(SAVE_VD)
except Exception:
print("no load_faiss_index")
embeddings = embedding()
faiss_index = FAISS.from_documents(docs, embeddings)
save_faiss_index(faiss_index, SAVE_VD)
@@ -168,10 +174,11 @@ if user_input := st.chat_input():
with st.spinner("문서 검색 및 답변 생성 중..."):
docs = reranker.invoke(user_input)
print(docs)
context_texts = "\n\n".join(
[
f"- {doc[0].metadata['source']} (유사도: {doc[1]}): {doc[0].page_content}"
f"- {doc[0].metadata['source']} (유사도: {doc[1]}): {doc[0].page_content}"
for doc in docs
]
)