EUNSEO56 commited on
Commit
2f50aae
·
1 Parent(s): 68d0a02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -24
app.py CHANGED
@@ -69,32 +69,13 @@ def get_text_chunks(documents):
69
 
70
 
71
  # 텍스트 청크들로부터 벡터 스토어를 생성하는 함수입니다.
72
- """def get_vectorstore(text_chunks):
73
- # OpenAI 임베딩 모델을 로드합니다. (Embedding models - Ada v2)
74
-
75
- embeddings = OpenAIEmbeddings()
76
- vectorstore = FAISS.from_documents(text_chunks, embeddings) # FAISS 벡터 스토어를 생성합니다.
77
-
78
- return vectorstore # 생성된 벡터 스토어를 반환합니다."""
79
  def get_vectorstore(text_chunks):
80
  # OpenAI 임베딩 모델을 로드합니다. (Embedding models - Ada v2)
81
- embeddings = OpenAIEmbeddings()
82
-
83
- # text_chunks에 적절한 텍스트가 있는지 확인
84
- if not text_chunks:
85
- st.warning("No text chunks found. Please check your input documents.")
86
- return None
87
-
88
- # embeddings 객체에서 길이를 가져와서 확인
89
- embedding_length = len(embeddings[text_chunks[0]]) if text_chunks and embeddings else 0
90
- if embedding_length == 0:
91
- st.warning("Embedding length is 0. Please check your embeddings and input documents.")
92
- return None
93
 
 
94
  vectorstore = FAISS.from_documents(text_chunks, embeddings) # FAISS 벡터 스토어를 생성합니다.
95
- return vectorstore
96
 
97
-
98
 
99
 
100
  def get_conversation_chain(vectorstore):
@@ -130,9 +111,8 @@ def handle_userinput(user_question):
130
 
131
  def main():
132
  load_dotenv()
133
-
134
- # set_page_config 함수는 스크립트의 처음에 호출되도록 이동
135
- st.set_page_config(page_title="Chat with multiple Files", page_icon=":books:")
136
  st.write(css, unsafe_allow_html=True)
137
 
138
  if "conversation" not in st.session_state or st.session_state.conversation is None:
 
69
 
70
 
71
  # 텍스트 청크들로부터 벡터 스토어를 생성하는 함수입니다.
 
 
 
 
 
 
 
72
  def get_vectorstore(text_chunks):
73
  # OpenAI 임베딩 모델을 로드합니다. (Embedding models - Ada v2)
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
+ embeddings = OpenAIEmbeddings()
76
  vectorstore = FAISS.from_documents(text_chunks, embeddings) # FAISS 벡터 스토어를 생성합니다.
 
77
 
78
+ return vectorstore # 생성된 벡터 스토어를 반환합니다.
79
 
80
 
81
  def get_conversation_chain(vectorstore):
 
111
 
112
  def main():
113
  load_dotenv()
114
+ st.set_page_config(page_title="Chat with multiple Files",
115
+ page_icon=":books:")
 
116
  st.write(css, unsafe_allow_html=True)
117
 
118
  if "conversation" not in st.session_state or st.session_state.conversation is None: