Spaces:
Sleeping
Sleeping
cleanup
Browse files
app.py
CHANGED
|
@@ -45,26 +45,6 @@ def encode_image(image_data):
|
|
| 45 |
|
| 46 |
return f"data:image/{image_type};base64,{base64.b64encode(image_data).decode('utf-8')}"
|
| 47 |
|
| 48 |
-
def add_file(history, files):
|
| 49 |
-
for file in files:
|
| 50 |
-
if file.name.endswith(".docx"):
|
| 51 |
-
content = process_docx(file.name)
|
| 52 |
-
else:
|
| 53 |
-
with open(file.name, mode="rb") as f:
|
| 54 |
-
content = f.read()
|
| 55 |
-
|
| 56 |
-
if isinstance(content, bytes):
|
| 57 |
-
content = content.decode('utf-8', 'replace')
|
| 58 |
-
else:
|
| 59 |
-
content = str(content)
|
| 60 |
-
|
| 61 |
-
fn = os.path.basename(file.name)
|
| 62 |
-
history = history + [(f'```{fn}\n{content}\n```', None)]
|
| 63 |
-
|
| 64 |
-
os.remove(file.name)
|
| 65 |
-
|
| 66 |
-
return history
|
| 67 |
-
|
| 68 |
def undo(history):
|
| 69 |
history.pop()
|
| 70 |
return history
|
|
|
|
| 45 |
|
| 46 |
return f"data:image/{image_type};base64,{base64.b64encode(image_data).decode('utf-8')}"
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def undo(history):
|
| 49 |
history.pop()
|
| 50 |
return history
|