Skip to content

Commit

Permalink
update validation logic for retry intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
spikelu2016 committed Jun 24, 2024
1 parent 6955298 commit afa1dde
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 1.29.0 - 2024-06-24
### Added
- Added support for Anthropic sonnet 3.5
- Added retry strategy to routes
- Added support for Azure OpenAI completions endpoint

### Changed
- Changed to using sha256 hashing algorithm for computing cache key within routes

## 1.28.4 - 2024-06-12
### Added
- Added filtering by status code for events v2 API
Expand Down
9 changes: 9 additions & 0 deletions docs/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,10 @@ components:
$ref: "#/components/schemas/StepConfigParams"
example: { "deploymentId": "ada-test", "apiVersion": "2022-12-01" }
description: Params required for making Azure OpenAI requests. Required if the provider is 'azure'.
retryInterval:
type: string
example: "1s"
description: Interval between each retry. Valid units are "ms" and "s".
timeout:
type: string
example: "5s"
Expand Down Expand Up @@ -1821,6 +1825,11 @@ components:
type: string
example: "/production/chat/completion"
description: Unique path for the route.
retryStrategy:
type: string
enum: ["exponential", "constant"]
example: "constant"
description: Different strategies for retries.
steps:
type: array
items:
Expand Down
11 changes: 11 additions & 0 deletions internal/manager/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@ func (m *RouteManager) validateRoute(r *route.Route) error {
fields = append(fields, fmt.Sprintf("steps.[%d].provider", index))
}

if len(step.RetryInterval) != 0 {
_, err := time.ParseDuration(step.RetryInterval)
if err != nil {
fields = append(fields, fmt.Sprintf("steps.[%d].retryInterval", index))
}

if !strings.HasSuffix(step.RetryInterval, "s") || !strings.HasSuffix(step.RetryInterval, "ms") {
fields = append(fields, fmt.Sprintf("steps.[%d].retryInterval", index))
}
}

if !contains(step.Provider, supportedProviders) {
return fmt.Errorf("steps.[%d].provider is not supported. Only azure and openai are supported", index)
}
Expand Down

0 comments on commit afa1dde

Please sign in to comment.