(r *route.Route)
| 261 | } |
| 262 | |
| 263 | func (m *RouteManager) validateRoute(r *route.Route) error { |
| 264 | fields := []string{} |
| 265 | |
| 266 | if len(r.Name) == 0 { |
| 267 | fields = append(fields, "name") |
| 268 | } |
| 269 | |
| 270 | if len(r.Path) == 0 { |
| 271 | fields = append(fields, "path") |
| 272 | } |
| 273 | |
| 274 | if len(r.KeyIds) == 0 { |
| 275 | fields = append(fields, "keyIds") |
| 276 | } |
| 277 | |
| 278 | if len(r.Steps) == 0 { |
| 279 | fields = append(fields, "steps") |
| 280 | } |
| 281 | |
| 282 | if len(r.RetryStrategy) != 0 && r.RetryStrategy != "exponential" && r.RetryStrategy != "constant" { |
| 283 | fields = append(fields, "retryStrategy") |
| 284 | } |
| 285 | |
| 286 | containAda := false |
| 287 | |
| 288 | for index, step := range r.Steps { |
| 289 | if len(step.Provider) == 0 { |
| 290 | fields = append(fields, fmt.Sprintf("steps.[%d].provider", index)) |
| 291 | } |
| 292 | |
| 293 | if len(step.RetryInterval) != 0 { |
| 294 | _, err := time.ParseDuration(step.RetryInterval) |
| 295 | if err != nil { |
| 296 | fields = append(fields, fmt.Sprintf("steps.[%d].retryInterval", index)) |
| 297 | } |
| 298 | |
| 299 | if !strings.HasSuffix(step.RetryInterval, "s") && !strings.HasSuffix(step.RetryInterval, "ms") { |
| 300 | fields = append(fields, fmt.Sprintf("steps.[%d].retryInterval", index)) |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | if !contains(step.Provider, supportedProviders) { |
| 305 | return fmt.Errorf("steps.[%d].provider is not supported. Only azure and openai are supported", index) |
| 306 | } |
| 307 | |
| 308 | if step.Provider == "azure" { |
| 309 | apiVersion := step.Params["apiVersion"] |
| 310 | if len(apiVersion) == 0 { |
| 311 | fields = append(fields, fmt.Sprintf("steps.[%d].params.apiVersion", index)) |
| 312 | } |
| 313 | |
| 314 | deploymentId := step.Params["deploymentId"] |
| 315 | if len(deploymentId) == 0 { |
| 316 | fields = append(fields, fmt.Sprintf("steps.[%d].params.deploymentId", index)) |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | if len(step.Model) == 0 { |
no test coverage detected