tntgroup commited on
Commit
db37cfa
·
1 Parent(s): 40fb7c0

fix: also limit count in auto-generate endpoint + slice custom items

Browse files
Files changed (1) hide show
  1. backend/app/api/listing_free.py +5 -2
backend/app/api/listing_free.py CHANGED
@@ -100,12 +100,13 @@ async def auto_generate(body: dict):
100
  product_info = body.get("product_info", "").strip()
101
  wangp_url = body.get("wangp_url", "").strip()
102
  model_choice = body.get("model_choice", "Wan2GP")
103
- resolution = body.get("resolution", "1088x1088")
104
  steps = body.get("steps", 20)
105
  guidance = body.get("guidance", 4)
106
  ref_strength = body.get("ref_strength", 75)
107
  negative_prompt = body.get("negative_prompt", "")
108
  custom_items = body.get("items") # optional, use instead of GPT prompts
 
109
 
110
  if not sid:
111
  raise HTTPException(400, "Missing session_id")
@@ -123,7 +124,7 @@ async def auto_generate(body: dict):
123
  s["status"] = "generating"
124
 
125
  if custom_items:
126
- items = custom_items
127
  else:
128
  if not openai_key:
129
  s["status"] = "error"
@@ -138,6 +139,8 @@ async def auto_generate(body: dict):
138
  s["status"] = "error"
139
  return {"ok": False, "error": f"GPT analysis failed: {str(e)}"}
140
 
 
 
141
  wangp_cfg = {
142
  "url": wangp_url,
143
  "model": model_choice,
 
100
  product_info = body.get("product_info", "").strip()
101
  wangp_url = body.get("wangp_url", "").strip()
102
  model_choice = body.get("model_choice", "Wan2GP")
103
+ resolution = body.get("resolution", "720x720")
104
  steps = body.get("steps", 20)
105
  guidance = body.get("guidance", 4)
106
  ref_strength = body.get("ref_strength", 75)
107
  negative_prompt = body.get("negative_prompt", "")
108
  custom_items = body.get("items") # optional, use instead of GPT prompts
109
+ count = min(body.get("count", 9), 9)
110
 
111
  if not sid:
112
  raise HTTPException(400, "Missing session_id")
 
124
  s["status"] = "generating"
125
 
126
  if custom_items:
127
+ items = custom_items[:count]
128
  else:
129
  if not openai_key:
130
  s["status"] = "error"
 
139
  s["status"] = "error"
140
  return {"ok": False, "error": f"GPT analysis failed: {str(e)}"}
141
 
142
+ items = items[:count]
143
+
144
  wangp_cfg = {
145
  "url": wangp_url,
146
  "model": model_choice,