limehee commited on
Commit
7eb5b29
·
1 Parent(s): fce7037

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -53,7 +53,10 @@ def get_json_file(json_docs):
53
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
54
  with open(temp_filepath, "wb") as f:
55
  f.write(json_docs.getvalue())
56
- json_loader = JSONLoader(temp_filepath, jq_schema='.messages[]', content_key="content", metadata_func=metadata_func)
 
 
 
57
  json_doc = json_loader.load()
58
  return json_doc
59
 
@@ -111,18 +114,6 @@ def handle_userinput(user_question):
111
  "{{MSG}}", message.content), unsafe_allow_html=True)
112
 
113
 
114
- def metadata_func(record: dict, metadata: dict) -> dict:
115
-
116
- metadata["sender_name"] = record.get("sender_name")
117
- metadata["timestamp_ms"] = record.get("timestamp_ms")
118
-
119
- if "source" in metadata:
120
- source = metadata["source"].split("/")
121
- source = source[source.index("langchain"):]
122
- metadata["source"] = "/".join(source)
123
-
124
- return metadata
125
-
126
  def main():
127
  load_dotenv()
128
  st.set_page_config(page_title="Chat with multiple Files",
 
53
  temp_filepath = os.path.join(temp_dir.name, json_docs.name)
54
  with open(temp_filepath, "wb") as f:
55
  f.write(json_docs.getvalue())
56
+ json_loader = JSONLoader(
57
+ file_path=temp_filepath,
58
+ jq_schema='.messages[].content',
59
+ text_content=False)
60
  json_doc = json_loader.load()
61
  return json_doc
62
 
 
114
  "{{MSG}}", message.content), unsafe_allow_html=True)
115
 
116
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  def main():
118
  load_dotenv()
119
  st.set_page_config(page_title="Chat with multiple Files",