Karin0616
commited on
Commit
Β·
3e98e85
1
Parent(s):
88106a3
json
Browse files
app.py
CHANGED
@@ -36,8 +36,16 @@ def get_csv_file(docs):
|
|
36 |
pass
|
37 |
|
38 |
def get_json_file(docs):
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
43 |
def get_text_chunks(documents):
|
|
|
36 |
pass
|
37 |
|
38 |
def get_json_file(docs):
|
39 |
+
temp_dir = tempfile.TemporaryDirectory() # μμ λλ ν 리λ₯Ό μμ±ν©λλ€.
|
40 |
+
temp_filepath = os.path.join(temp_dir.name, docs.name) # μμ νμΌ κ²½λ‘λ₯Ό μμ±ν©λλ€.
|
41 |
+
with open(temp_filepath, "wb") as f: # μμ νμΌμ λ°μ΄λ리 μ°κΈ° λͺ¨λλ‘ μ½λλ€.
|
42 |
+
f.write(docs.getvalue())
|
43 |
+
json_loader = JSONLoader(
|
44 |
+
file_path=temp_filepath,
|
45 |
+
jq_schema='.messages[].content',
|
46 |
+
text_content=False)
|
47 |
+
json_doc = json_loader.load()
|
48 |
+
return json_doc
|
49 |
|
50 |
# λ¬Έμλ€μ μ²λ¦¬νμ¬ ν
μ€νΈ μ²ν¬λ‘ λλλ ν¨μμ
λλ€.
|
51 |
def get_text_chunks(documents):
|