Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,7 @@ def CompressXML(xml_text, max_length):
|
|
90 |
elem.parent.remove(elem)
|
91 |
return ET.tostring(root, encoding='unicode', method="xml")[:max_length]
|
92 |
|
93 |
-
def read_file_content(file):
|
94 |
if file.type == "application/json":
|
95 |
content = json.load(file)
|
96 |
return str(content)
|
@@ -101,7 +101,7 @@ def read_file_content(file):
|
|
101 |
tree = ET.parse(file)
|
102 |
root = tree.getroot()
|
103 |
#return ET.tostring(root, encoding='unicode')
|
104 |
-
return CompressXML(ET.tostring(root, encoding='unicode',max_length)
|
105 |
elif file.type == "text/markdown" or file.type == "text/md":
|
106 |
md = mistune.create_markdown()
|
107 |
content = md(file.read().decode())
|
@@ -121,7 +121,7 @@ def main():
|
|
121 |
prompts.append(user_prompt)
|
122 |
|
123 |
if uploaded_file is not None:
|
124 |
-
file_content = read_file_content(uploaded_file)
|
125 |
prompts.append(file_content)
|
126 |
|
127 |
if st.button('π¬ Chat'):
|
|
|
90 |
elem.parent.remove(elem)
|
91 |
return ET.tostring(root, encoding='unicode', method="xml")[:max_length]
|
92 |
|
93 |
+
def read_file_content(file,max_length):
|
94 |
if file.type == "application/json":
|
95 |
content = json.load(file)
|
96 |
return str(content)
|
|
|
101 |
tree = ET.parse(file)
|
102 |
root = tree.getroot()
|
103 |
#return ET.tostring(root, encoding='unicode')
|
104 |
+
return CompressXML(ET.tostring(root, encoding='unicode',max_length))
|
105 |
elif file.type == "text/markdown" or file.type == "text/md":
|
106 |
md = mistune.create_markdown()
|
107 |
content = md(file.read().decode())
|
|
|
121 |
prompts.append(user_prompt)
|
122 |
|
123 |
if uploaded_file is not None:
|
124 |
+
file_content = read_file_content(uploaded_file, max_length)
|
125 |
prompts.append(file_content)
|
126 |
|
127 |
if st.button('π¬ Chat'):
|