michaelmc1618 commited on
Commit
740fbb9
·
verified ·
1 Parent(s): 98eff7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -50,15 +50,17 @@ def evaluate_pci_compliance(audit_data):
50
  compliance_analysis = respond(audit_data, system_message, max_tokens=1024, temperature=0.7, top_p=0.95)
51
  return compliance_analysis
52
 
 
53
  def analyze_json_file(file_obj):
54
- # Assuming file_obj is a file-like object from Gradio
55
- try:
56
- # Read and decode the file if it's a file-like object
57
- file_str = file_obj.read().decode("utf-8")
58
- except AttributeError:
59
- # Handle if it's a byte string directly
60
  file_str = file_obj.decode("utf-8")
61
-
 
 
 
 
 
62
  json_data = json.loads(file_str)
63
  audit_data = json.dumps(json_data, indent=2) # Convert JSON to a formatted string
64
  return audit_data
 
50
  compliance_analysis = respond(audit_data, system_message, max_tokens=1024, temperature=0.7, top_p=0.95)
51
  return compliance_analysis
52
 
53
+ # Analyze JSON file input
54
  def analyze_json_file(file_obj):
55
+ # Handle both file-like objects and strings properly
56
+ if isinstance(file_obj, bytes):
 
 
 
 
57
  file_str = file_obj.decode("utf-8")
58
+ elif isinstance(file_obj, str):
59
+ file_str = file_obj
60
+ else:
61
+ # Assuming it's a file-like object, read the content as a string
62
+ file_str = file_obj.read().decode("utf-8")
63
+
64
  json_data = json.loads(file_str)
65
  audit_data = json.dumps(json_data, indent=2) # Convert JSON to a formatted string
66
  return audit_data