소스 검색

✨ feat(middleware): enhance Kling request adapter to support both 'model' and 'model_name' fields

Previously, the KlingRequestConvert middleware only extracted model name from
the 'model_name' field, which caused 503 errors when requests used the 'model'
field instead. This enhancement improves API compatibility by supporting both
field names.

Changes:
- Modified KlingRequestConvert() to check for 'model' field if 'model_name' is empty
- Maintains backward compatibility with existing 'model_name' usage
- Fixes "no available channels for model" error when model field was not recognized

This resolves issues where valid Kling API requests were failing due to field
name mismatches, improving the overall user experience for video generation APIs.
t0ng7u 9 달 전
부모
커밋
d0589468c1
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      middleware/kling_adapter.go

+ 4 - 0
middleware/kling_adapter.go

@@ -18,7 +18,11 @@ func KlingRequestConvert() func(c *gin.Context) {
 			return
 		}
 
+		// 支持 model_name 和 model 两个字段
 		model, _ := originalReq["model_name"].(string)
+		if model == "" {
+			model, _ = originalReq["model"].(string)
+		}
 		prompt, _ := originalReq["prompt"].(string)
 
 		unifiedReq := map[string]interface{}{