Oranblock commited on
Commit
1ac9747
1 Parent(s): 3e58ae6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -24,8 +24,17 @@ def analyze_and_fix_shell_script(script_content):
24
 
25
  # Gradio interface to upload shell script and process
26
  def upload_and_fix(file):
27
- script_content = file.read().decode("utf-8")
 
 
 
 
 
 
 
 
28
  fixed_script = analyze_and_fix_shell_script(script_content)
 
29
  return fixed_script
30
 
31
  # Create a Gradio interface
 
24
 
25
  # Gradio interface to upload shell script and process
26
  def upload_and_fix(file):
27
+ # Check if file is a NamedString or IO type object and handle it accordingly
28
+ if isinstance(file, (bytes, str)):
29
+ # Decode the content if it's in byte/string format
30
+ script_content = file.decode("utf-8")
31
+ else:
32
+ # Otherwise, it's already a string
33
+ script_content = file
34
+
35
+ # Analyze and fix the shell script using GPT
36
  fixed_script = analyze_and_fix_shell_script(script_content)
37
+
38
  return fixed_script
39
 
40
  # Create a Gradio interface