-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#67: Restructure router config, model & provider interfaces to incorp…
…orate the new embedding router
- Loading branch information
1 parent
27347ec
commit d842fa0
Showing
59 changed files
with
343 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
.idea | ||
dist | ||
.env | ||
.env.bak | ||
config.yaml | ||
bin | ||
glide | ||
glide.exe | ||
tmp | ||
coverage.txt | ||
precommit.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/EinStack/glide/pkg/clients" | ||
"github.com/EinStack/glide/pkg/resiliency/health" | ||
"github.com/EinStack/glide/pkg/routers/latency" | ||
"github.com/EinStack/glide/pkg/telemetry" | ||
) | ||
|
||
type Config[P any] struct { | ||
ID string `yaml:"id" json:"id" validate:"required"` // Model instance ID (unique in scope of the router) | ||
Enabled bool `yaml:"enabled" json:"enabled" validate:"required"` // Is the model enabled? | ||
ErrorBudget *health.ErrorBudget `yaml:"error_budget" json:"error_budget" swaggertype:"primitive,string"` | ||
Latency *latency.Config `yaml:"latency" json:"latency"` | ||
Weight int `yaml:"weight" json:"weight"` | ||
Client *clients.ClientConfig `yaml:"client" json:"client"` | ||
|
||
Provider P `yaml:"provider" json:"provider"` | ||
} | ||
|
||
func DefaultConfig[P any]() Config[P] { | ||
return Config[P]{ | ||
Enabled: true, | ||
Client: clients.DefaultClientConfig(), | ||
ErrorBudget: health.DefaultErrorBudget(), | ||
Latency: latency.DefaultConfig(), | ||
Weight: 1, | ||
} | ||
} | ||
|
||
func (c *Config) ToModel(tel *telemetry.Telemetry) (*LanguageModel, error) { | ||
client, err := c.Provider.ToClient(tel, c.Client) | ||
if err != nil { | ||
return nil, fmt.Errorf("error initializing client: %w", err) | ||
} | ||
|
||
return NewLangModel(c.ID, client, c.ErrorBudget, *c.Latency, c.Weight), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package models | ||
|
||
import "github.com/EinStack/glide/pkg/config/fields" | ||
|
||
// Model represent a configured external modality-agnostic model with its routing properties and status | ||
type Model interface { | ||
ID() string | ||
Healthy() bool | ||
LatencyUpdateInterval() *fields.Duration | ||
Weight() int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.