EUNSEO56 commited on
Commit
1fb2830
·
1 Parent(s): 3c26b7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -69,13 +69,32 @@ 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
 
80
 
81
  def get_conversation_chain(vectorstore):
 
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):