[email protected] commited on
Commit
a7f4e5b
ยท
1 Parent(s): b2646b2

edit codes

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -72,9 +72,17 @@ def get_text_chunks(documents):
72
  chunk_overlap=200, # ์ฒญํฌ ์‚ฌ์ด์˜ ์ค‘๋ณต์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
73
  length_function=len # ํ…์ŠคํŠธ์˜ ๊ธธ์ด๋ฅผ ์ธก์ •ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
74
  )
 
 
 
 
 
 
 
 
75
 
76
- documents = text_splitter.split_documents(documents) # ๋ฌธ์„œ๋“ค์„ ์ฒญํฌ๋กœ ๋‚˜๋ˆ•๋‹ˆ๋‹ค
77
- return documents # ๋‚˜๋ˆˆ ์ฒญํฌ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
78
 
79
 
80
  # ํ…์ŠคํŠธ ์ฒญํฌ๋“ค๋กœ๋ถ€ํ„ฐ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
 
72
  chunk_overlap=200, # ์ฒญํฌ ์‚ฌ์ด์˜ ์ค‘๋ณต์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
73
  length_function=len # ํ…์ŠคํŠธ์˜ ๊ธธ์ด๋ฅผ ์ธก์ •ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
74
  )
75
+ texts = []
76
+ for doc in documents:
77
+ if isinstance(doc, str):
78
+ # doc์ด ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ ์ง์ ‘ texts์— ์ถ”๊ฐ€
79
+ texts.append(doc)
80
+ else:
81
+ # doc์ด 'page_content' ์†์„ฑ์„ ๊ฐ–์ถ˜ ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ
82
+ texts.append(doc.page_content)
83
 
84
+ chunks = text_splitter.split_documents(texts)
85
+ return chunks
86
 
87
 
88
  # ํ…์ŠคํŠธ ์ฒญํฌ๋“ค๋กœ๋ถ€ํ„ฐ ๋ฒกํ„ฐ ์Šคํ† ์–ด๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.