-
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: Started to connect EmbedRouter into the system
- Loading branch information
1 parent
d1659d3
commit e526611
Showing
4 changed files
with
71 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package schemas | ||
|
||
type EmbedRequest struct { | ||
// TODO: implement | ||
} | ||
|
||
type EmbedResponse struct { | ||
// TODO: implement | ||
} |
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 |
---|---|---|
@@ -1,16 +1,59 @@ | ||
package router | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/EinStack/glide/pkg/extmodel" | ||
"github.com/EinStack/glide/pkg/provider" | ||
"github.com/EinStack/glide/pkg/telemetry" | ||
"go.uber.org/multierr" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type ( | ||
EmbedModelConfig = extmodel.Config[*provider.Config] | ||
EmbedModelPoolConfig = []EmbedModelConfig | ||
) | ||
|
||
type EmbeddingRouterConfig struct { | ||
type EmbedRouterConfig struct { | ||
Config | ||
Models EmbedModelPoolConfig `yaml:"models" json:"models" validate:"required,min=1,dive"` // the list of models that could handle requests | ||
} | ||
|
||
type EmbedRoutersConfig []EmbedRouterConfig | ||
|
||
func (c EmbedRoutersConfig) Build(tel *telemetry.Telemetry) ([]*EmbedRouter, error) { | ||
seenIDs := make(map[string]bool, len(c)) | ||
routers := make([]*EmbedRouter, 0, len(c)) | ||
|
||
var errs error | ||
|
||
for idx, routerConfig := range c { | ||
if _, ok := seenIDs[routerConfig.ID]; ok { | ||
return nil, fmt.Errorf("ID \"%v\" is specified for more than one router while each ID should be unique", routerConfig.ID) | ||
} | ||
|
||
seenIDs[routerConfig.ID] = true | ||
|
||
if !routerConfig.Enabled { | ||
tel.L().Info(fmt.Sprintf("Embed router \"%v\" is disabled, skipping", routerConfig.ID)) | ||
continue | ||
} | ||
|
||
tel.L().Debug("Init router", zap.String("routerID", routerConfig.ID)) | ||
|
||
r, err := NewEmbedRouter(&c[idx], tel) | ||
if err != nil { | ||
errs = multierr.Append(errs, err) | ||
continue | ||
} | ||
|
||
routers = append(routers, r) | ||
} | ||
|
||
if errs != nil { | ||
return nil, errs | ||
} | ||
|
||
return routers, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
package router | ||
|
||
type EmbeddingRouter struct { | ||
import ( | ||
"context" | ||
|
||
"github.com/EinStack/glide/pkg/api/schemas" | ||
"github.com/EinStack/glide/pkg/telemetry" | ||
) | ||
|
||
type EmbedRouter struct { | ||
// routerID lang.RouterID | ||
// Config *LangRouterConfig | ||
// retry *retry.ExpRetry | ||
// tel *telemetry.Telemetry | ||
// logger *zap.Logger | ||
} | ||
|
||
//func (r *EmbeddingRouter) Embed(ctx context.Context, req *schemas.EmbedRequest) (*schemas.EmbedResponse, error) { | ||
//} | ||
func NewEmbedRouter(_ *EmbedRouterConfig, _ *telemetry.Telemetry) (*EmbedRouter, error) { | ||
// TODO: implement | ||
return &EmbedRouter{}, nil | ||
} | ||
|
||
func (r *EmbedRouter) Embed(ctx context.Context, req *schemas.EmbedRequest) (*schemas.EmbedResponse, error) { | ||
// TODO: implement | ||
} | ||
Check failure on line 25 in pkg/router/embed_router.go GitHub Actions / Build
Check failure on line 25 in pkg/router/embed_router.go GitHub Actions / Vulnerability Check
Check failure on line 25 in pkg/router/embed_router.go GitHub Actions / Lint
|