Spaces:
Runtime error
Runtime error
JinHyeong99
commited on
Commit
Β·
7d47c0f
1
Parent(s):
8c31276
app.py
CHANGED
@@ -34,14 +34,13 @@ def get_text_file(text_docs):
|
|
34 |
return text_doc
|
35 |
|
36 |
def get_csv_file(csv_docs):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
return csv_doc # μΆμΆν ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
45 |
|
46 |
|
47 |
def get_json_file(json_docs):
|
@@ -52,8 +51,8 @@ def get_json_file(json_docs):
|
|
52 |
jq_schema='.messages[].content',
|
53 |
text_content=False)
|
54 |
|
55 |
-
|
56 |
-
return
|
57 |
|
58 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
59 |
def get_text_chunks(documents):
|
@@ -132,7 +131,7 @@ def main():
|
|
132 |
|
133 |
st.subheader("λ¬Έμ μ¬λ¦¬κΈ°")
|
134 |
docs = st.file_uploader(
|
135 |
-
"λ¬Έμλ₯Ό μ
λ‘λ ν ν Process λ²νΌμ ν΄λ¦νμΈμ.
|
136 |
if st.button("Process"):
|
137 |
with st.spinner("Processing"):
|
138 |
# get pdf text
|
|
|
34 |
return text_doc
|
35 |
|
36 |
def get_csv_file(csv_docs):
|
37 |
+
temp_dir = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
38 |
+
temp_filepath = os.path.join(temp_dir.name, csv_docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
39 |
+
with open(temp_filepath, "wb") as f: # μμ νμΌμ λ°μ΄λ리 μ°κΈ° λͺ¨λλ‘ μ½λλ€.
|
40 |
+
f.write(csv_docs.getvalue()) # CSV λ¬Έμμ λ΄μ©μ μμ νμΌμ μλλ€.
|
41 |
+
csv_loader = CSVLoader(temp_filepath) # CSVLoader μΈμ€ν΄μ€λ₯Ό μμ±ν©λλ€.
|
42 |
+
csv_doc = csv_loader.load() # ν
μ€νΈλ₯Ό μΆμΆν©λλ€.
|
43 |
+
return csv_doc # μΆμΆν ν
μ€νΈλ₯Ό λ°νν©λλ€.
|
|
|
44 |
|
45 |
|
46 |
def get_json_file(json_docs):
|
|
|
51 |
jq_schema='.messages[].content',
|
52 |
text_content=False)
|
53 |
|
54 |
+
json_doc = loader.load()
|
55 |
+
return json_doc
|
56 |
|
57 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
58 |
def get_text_chunks(documents):
|
|
|
131 |
|
132 |
st.subheader("λ¬Έμ μ¬λ¦¬κΈ°")
|
133 |
docs = st.file_uploader(
|
134 |
+
"λ¬Έμλ₯Ό μ
λ‘λ ν ν Process λ²νΌμ ν΄λ¦νμΈμ.", accept_multiple_files=True)
|
135 |
if st.button("Process"):
|
136 |
with st.spinner("Processing"):
|
137 |
# get pdf text
|