lds204 commited on
Commit
071b15f
Β·
1 Parent(s): b2810bc
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -11,7 +11,6 @@ from langchain.document_loaders import PyPDFLoader, TextLoader, JSONLoader
11
  from langchain.document_loaders.csv_loader import CSVLoader
12
  import json
13
  from pathlib import Path
14
- from pprint import pprint
15
  import tempfile # μž„μ‹œ νŒŒμΌμ„ μƒμ„±ν•˜κΈ° μœ„ν•œ λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
16
  import os
17
  from huggingface_hub import hf_hub_download # Hugging Face Hubμ—μ„œ λͺ¨λΈμ„ λ‹€μš΄λ‘œλ“œν•˜κΈ° μœ„ν•œ ν•¨μˆ˜μž…λ‹ˆλ‹€.
@@ -51,11 +50,13 @@ def get_json_file(json_docs):
51
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
52
  with open(temp_filepath, "wb") as f: # μž„μ‹œ νŒŒμΌμ„ λ°”μ΄λ„ˆλ¦¬ μ“°κΈ° λͺ¨λ“œλ‘œ μ—½λ‹ˆλ‹€.
53
  f.write(json_docs.getvalue())
54
- json_loader = JSONLoader(
55
- file_path = temp_filepath,
56
- jq_schema='.messages[].content',
57
- text_content=False)
58
- json_doc = json_loader.load()
 
 
59
  return json_doc
60
 
61
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
11
  from langchain.document_loaders.csv_loader import CSVLoader
12
  import json
13
  from pathlib import Path
 
14
  import tempfile # μž„μ‹œ νŒŒμΌμ„ μƒμ„±ν•˜κΈ° μœ„ν•œ λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
15
  import os
16
  from huggingface_hub import hf_hub_download # Hugging Face Hubμ—μ„œ λͺ¨λΈμ„ λ‹€μš΄λ‘œλ“œν•˜κΈ° μœ„ν•œ ν•¨μˆ˜μž…λ‹ˆλ‹€.
 
50
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
51
  with open(temp_filepath, "wb") as f: # μž„μ‹œ νŒŒμΌμ„ λ°”μ΄λ„ˆλ¦¬ μ“°κΈ° λͺ¨λ“œλ‘œ μ—½λ‹ˆλ‹€.
52
  f.write(json_docs.getvalue())
53
+ # json_loader = JSONLoader(
54
+ # file_path = temp_filepath,
55
+ # jq_schema='.messages[].content',
56
+ # text_content=False)
57
+
58
+ # json_doc = json_loader.load()
59
+ json_doc = json.loads(Path(temp_filepath).read_text())
60
  return json_doc
61
 
62
  # λ¬Έμ„œλ“€μ„ μ²˜λ¦¬ν•˜μ—¬ ν…μŠ€νŠΈ 청크둜 λ‚˜λˆ„λŠ” ν•¨μˆ˜μž…λ‹ˆλ‹€.