Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,14 +7,14 @@ client = InferenceClient("Qwen/Qwen2.5-Coder-32B-Instruct")
|
|
7 |
uploaded_file_content = ""
|
8 |
|
9 |
# A function to handle file upload and store content
|
10 |
-
def handle_file_upload(
|
11 |
global uploaded_file_content
|
12 |
-
if
|
13 |
return "No file uploaded."
|
14 |
|
15 |
try:
|
16 |
-
#
|
17 |
-
content =
|
18 |
|
19 |
# Try to decode as UTF-8
|
20 |
try:
|
@@ -97,7 +97,7 @@ with demo:
|
|
97 |
file_upload = gr.File(
|
98 |
label="Upload a text file",
|
99 |
file_types=[".txt"],
|
100 |
-
type="
|
101 |
)
|
102 |
upload_button = gr.Button("Upload File")
|
103 |
upload_output = gr.Textbox(
|
|
|
7 |
uploaded_file_content = ""
|
8 |
|
9 |
# A function to handle file upload and store content
|
10 |
+
def handle_file_upload(file_obj):
|
11 |
global uploaded_file_content
|
12 |
+
if file_obj is None:
|
13 |
return "No file uploaded."
|
14 |
|
15 |
try:
|
16 |
+
# The file is already passed as bytes in the newest Gradio version
|
17 |
+
content = file_obj
|
18 |
|
19 |
# Try to decode as UTF-8
|
20 |
try:
|
|
|
97 |
file_upload = gr.File(
|
98 |
label="Upload a text file",
|
99 |
file_types=[".txt"],
|
100 |
+
type="bytes" # Changed to bytes type
|
101 |
)
|
102 |
upload_button = gr.Button("Upload File")
|
103 |
upload_output = gr.Textbox(
|