Error out if API key is not given

#1
by xianbao HF staff - opened
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -5,6 +5,10 @@ import io
5
 
6
  # 修改 generate_image 函数以处理图像生成并保存为临时文件
7
  def generate_image(api_key, prompt, aspect_ratio, model, negative_prompt, seed):
 
 
 
 
8
  response = requests.post(
9
  "https://api.stability.ai/v2beta/stable-image/generate/sd3",
10
  headers={
 
5
 
6
  # 修改 generate_image 函数以处理图像生成并保存为临时文件
7
  def generate_image(api_key, prompt, aspect_ratio, model, negative_prompt, seed):
8
+
9
+ if not api_key or not api_key.strip():
10
+ raise gr.Error("Please enter API key")
11
+
12
  response = requests.post(
13
  "https://api.stability.ai/v2beta/stable-image/generate/sd3",
14
  headers={