Walid-Ahmed commited on
Commit
2f7310c
·
verified ·
1 Parent(s): 657ef73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -20,7 +20,12 @@ def process(context_file, question):
20
  raw_data = file.read()
21
  result = chardet.detect(raw_data)
22
  encoding = result['encoding']
23
- context = raw_data.decode(encoding, errors='replace') # Replace errors with placeholder
 
 
 
 
 
24
 
25
 
26
  answer = answer_question(context, question)
 
20
  raw_data = file.read()
21
  result = chardet.detect(raw_data)
22
  encoding = result['encoding']
23
+
24
+ # Fallback to a default encoding if detection fails
25
+ if encoding is None:
26
+ encoding = 'utf-8' # You can change this to another default encoding
27
+
28
+ context = raw_data.decode(encoding, errors='replace') # Replace errors with a placeholder
29
 
30
 
31
  answer = answer_question(context, question)