PCFISH commited on
Commit
af69459
โ€ข
1 Parent(s): f1ec1d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -67,17 +67,18 @@ def get_text_chunks(documents):
67
  # ๊ฐ ๋ฌธ์„œ์˜ ๋‚ด์šฉ์„ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€
68
  texts = []
69
  for doc in documents:
70
- if isinstance(doc, str):
 
 
 
71
  # ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ ๊ทธ๋Œ€๋กœ ์ถ”๊ฐ€
72
  texts.append(doc)
73
- else:
74
- # ๊ทธ ์™ธ์˜ ๊ฒฝ์šฐ์—๋Š” ๋ฌธ์„œ์˜ ๋‚ด์šฉ์„ ์ถ”๊ฐ€
75
- texts.append(doc.page_content)
76
 
77
  # ๋‚˜๋ˆˆ ์ฒญํฌ๋ฅผ ๋ฐ˜ํ™˜
78
  return text_splitter.split_documents(texts)
79
 
80
 
 
81
  # ํ…์ŠคํŠธ ์ฒญํฌ๋“ค๋กœ๋ถ€ํ„ฐ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
82
  def get_vectorstore(text_chunks):
83
  # OpenAI ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. (Embedding models - Ada v2)
 
67
  # ๊ฐ ๋ฌธ์„œ์˜ ๋‚ด์šฉ์„ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€
68
  texts = []
69
  for doc in documents:
70
+ if hasattr(doc, 'page_content'):
71
+ # ๋ฌธ์„œ ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ์—๋งŒ ์ถ”๊ฐ€
72
+ texts.append(doc.page_content)
73
+ elif isinstance(doc, str):
74
  # ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ ๊ทธ๋Œ€๋กœ ์ถ”๊ฐ€
75
  texts.append(doc)
 
 
 
76
 
77
  # ๋‚˜๋ˆˆ ์ฒญํฌ๋ฅผ ๋ฐ˜ํ™˜
78
  return text_splitter.split_documents(texts)
79
 
80
 
81
+
82
  # ํ…์ŠคํŠธ ์ฒญํฌ๋“ค๋กœ๋ถ€ํ„ฐ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
83
  def get_vectorstore(text_chunks):
84
  # OpenAI ์ž„๋ฒ ๋”ฉ ๋ชจ๋ธ์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. (Embedding models - Ada v2)