Skip to content

Commit

Permalink
#46: Hardcoding routing values temporarily to keep OpenAPI spec gener…
Browse files Browse the repository at this point in the history
…ation deterministic
  • Loading branch information
roma-glushko committed Jan 14, 2024
1 parent f64b718 commit 4f317de
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
7 changes: 6 additions & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ const docTemplate = `{
},
"strategy": {
"description": "strategy on picking the next model to serve the request",
"enum": [
"least_latency",
"round_robin",
"priority"
],
"allOf": [
{
"$ref": "#/definitions/routing.Strategy"
Expand All @@ -422,7 +427,7 @@ const docTemplate = `{
"enum": [
"least_latency",
"priority",
"round-robin"
"round_robin"
],
"x-enum-varnames": [
"LeastLatency",
Expand Down
7 changes: 6 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@
},
"strategy": {
"description": "strategy on picking the next model to serve the request",
"enum": [
"least_latency",
"round_robin",
"priority"
],
"allOf": [
{
"$ref": "#/definitions/routing.Strategy"
Expand All @@ -419,7 +424,7 @@
"enum": [
"least_latency",
"priority",
"round-robin"
"round_robin"
],
"x-enum-varnames": [
"LeastLatency",
Expand Down
6 changes: 5 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ definitions:
allOf:
- $ref: '#/definitions/routing.Strategy'
description: strategy on picking the next model to serve the request
enum:
- least_latency
- round_robin
- priority
required:
- models
- routers
Expand All @@ -201,7 +205,7 @@ definitions:
enum:
- least_latency
- priority
- round-robin
- round_robin
type: string
x-enum-varnames:
- LeastLatency
Expand Down
10 changes: 5 additions & 5 deletions pkg/routers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func (c *Config) BuildLangRouters(tel *telemetry.Telemetry) ([]*LangRouter, erro
// TODO: how to specify other backoff strategies?
// LangRouterConfig
type LangRouterConfig struct {
ID string `yaml:"id" json:"routers" validate:"required"` // Unique router ID
Enabled bool `yaml:"enabled" json:"enabled"` // Is router enabled?
Retry *retry.ExpRetryConfig `yaml:"retry" json:"retry"` // retry when no healthy model is available to router
RoutingStrategy routing.Strategy `yaml:"strategy" json:"strategy"` // strategy on picking the next model to serve the request
Models []providers.LangModelConfig `yaml:"models" json:"models" validate:"required"` // the list of models that could handle requests
ID string `yaml:"id" json:"routers" validate:"required"` // Unique router ID
Enabled bool `yaml:"enabled" json:"enabled"` // Is router enabled?
Retry *retry.ExpRetryConfig `yaml:"retry" json:"retry"` // retry when no healthy model is available to router
RoutingStrategy routing.Strategy `yaml:"strategy" json:"strategy" enums:"least_latency,round_robin,priority"` // strategy on picking the next model to serve the request
Models []providers.LangModelConfig `yaml:"models" json:"models" validate:"required"` // the list of models that could handle requests
}

// BuildModels creates LanguageModel slice out of the given config
Expand Down
2 changes: 1 addition & 1 deletion pkg/routers/routing/round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
RoundRobin Strategy = "round-robin"
RoundRobin Strategy = "round_robin"
)

// RoundRobinRouting routes request to the next model in the list in cycle
Expand Down

0 comments on commit 4f317de

Please sign in to comment.