hyonee commited on
Commit
b114f08
ยท
1 Parent(s): 5901b4e
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -84,8 +84,19 @@ def get_vectorstore(text_chunks):
84
  # OpenAI ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. (Embedding models - Ada v2)
85
 
86
  embeddings = OpenAIEmbeddings()
87
- vectorstore = FAISS.from_documents(text_chunks, embeddings) # FAISS ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
88
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  return vectorstore # ์ƒ์„ฑ๋œ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
90
 
91
 
 
84
  # OpenAI ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. (Embedding models - Ada v2)
85
 
86
  embeddings = OpenAIEmbeddings()
 
87
 
88
+ # ํ…์ŠคํŠธ ์ฒญํฌ๊ฐ€ ๋น„์–ด ์žˆ๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
89
+ if not text_chunks or not text_chunks[0]:
90
+ return None
91
+
92
+ # ์ฒซ ๋ฒˆ์งธ ํ…์ŠคํŠธ ์ฒญํฌ์˜ ๊ธธ์ด ํ™•์ธ
93
+ first_chunk_length = len(text_chunks[0])
94
+
95
+ # ์ฒซ ๋ฒˆ์งธ ํ…์ŠคํŠธ ์ฒญํฌ๊ฐ€ ๋น„์–ด ์žˆ๋Š” ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
96
+ if first_chunk_length == 0:
97
+ return None
98
+
99
+ vectorstore = FAISS.from_documents(text_chunks, embeddings) # FAISS ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
100
  return vectorstore # ์ƒ์„ฑ๋œ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
101
 
102