Sergidev commited on
Commit
eb9e832
·
verified ·
1 Parent(s): 2360e47

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +14 -1
utils.py CHANGED
@@ -91,4 +91,17 @@ def is_google_colab():
91
  import google.colab
92
  return True
93
  except:
94
- return False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  import google.colab
92
  return True
93
  except:
94
+ return False
95
+
96
+ def validate_json_parameters(json_str):
97
+ try:
98
+ params = json.loads(json_str)
99
+ required_keys = ['prompt', 'negative_prompt', 'seed', 'width', 'height', 'guidance_scale', 'num_inference_steps', 'sampler']
100
+ for key in required_keys:
101
+ if key not in params:
102
+ raise ValueError(f"Missing required key: {key}")
103
+ return params
104
+ except json.JSONDecodeError:
105
+ raise ValueError("Invalid JSON format")
106
+ except Exception as e:
107
+ raise ValueError(f"Error parsing JSON: {str(e)}")