Skip to content

Commit

Permalink
#67: Onboarded cohere to the new Configurer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-glushko committed Aug 8, 2024
1 parent 5ad821c commit 4aa7b2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/provider/cohere/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cohere

import (
"github.com/EinStack/glide/pkg/clients"
"github.com/EinStack/glide/pkg/config/fields"
"github.com/EinStack/glide/pkg/provider"
"github.com/EinStack/glide/pkg/telemetry"
)

// Params defines Cohere-specific model params with the specific validation of values
Expand Down Expand Up @@ -58,6 +61,10 @@ func DefaultConfig() *Config {
}
}

func (c *Config) ToClient(tel *telemetry.Telemetry, clientConfig *clients.ClientConfig) (provider.LangProvider, error) {
return NewClient(c, clientConfig, tel)
}

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = *DefaultConfig()

Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/cohere/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cohere

import "github.com/EinStack/glide/pkg/provider"

func init() {
provider.LangRegistry.Register(ProviderID, &Config{})
}
5 changes: 4 additions & 1 deletion pkg/provider/openai/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ type Config struct {
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

var _ provider.Configurer = (*Config)(nil)
// ensure interfaces
var (
_ provider.Configurer = (*Config)(nil)
)

// DefaultConfig for OpenAI models
func DefaultConfig() *Config {
Expand Down

0 comments on commit 4aa7b2b

Please sign in to comment.