diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1a09552 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3" +services: + app: + build: . + volumes: + - .:/opt/workspace # 로컬 디렉토리와 컨테이너 디렉토리 동기화 + ports: + - "8501:8501" # Streamlit 앱 포트 설정 + container_name: streamlit-rag # 컨테이너 이름 설정 diff --git a/dockerfile b/dockerfile index cdc3da4..45c9f8c 100644 --- a/dockerfile +++ b/dockerfile @@ -1,6 +1,7 @@ FROM pytorch/pytorch:latest -WORKDIR /app +ADD . /opt/workspace +WORKDIR /opt/workspace # 필수 패키지 설치 RUN apt-get update && apt-get install -y python3-pip diff --git a/main.py b/main.py index 6069259..3c3e9c3 100644 --- a/main.py +++ b/main.py @@ -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 ] )