TeacherPuffy commited on
Commit
a4e88d8
·
verified ·
1 Parent(s): a40cc94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -41,8 +41,14 @@ def process_text(file, prompt):
41
  try:
42
  logger.info("Starting text processing...")
43
 
44
- # Read the text directly from the uploaded file
45
- text = file # The file content is already a string
 
 
 
 
 
 
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