Spaces:
Running
Running
TeacherPuffy
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -41,8 +41,14 @@ def process_text(file, prompt):
|
|
41 |
try:
|
42 |
logger.info("Starting text processing...")
|
43 |
|
44 |
-
# Read the
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
logger.info(f"Text length: {len(text)} characters.")
|
47 |
|
48 |
# Segment the text into chunks
|
|
|
41 |
try:
|
42 |
logger.info("Starting text processing...")
|
43 |
|
44 |
+
# Read the file content properly
|
45 |
+
if hasattr(file, "read"):
|
46 |
+
# If the file is a file-like object, read its content
|
47 |
+
text = file.read().decode('utf-8') # Decode bytes to string
|
48 |
+
else:
|
49 |
+
# If the file is already a string, use it directly
|
50 |
+
text = file
|
51 |
+
|
52 |
logger.info(f"Text length: {len(text)} characters.")
|
53 |
|
54 |
# Segment the text into chunks
|