Skip to content

Commit

Permalink
#67: Onboarded anthropic 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 4aa7b2b commit d1cb962
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/provider/anthropic/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
response := schemas.ChatResponse{
ID: anthropicResponse.ID,
Created: int(time.Now().UTC().Unix()), // not provided by anthropic
Provider: providerName,
Provider: ProviderID,
ModelName: anthropicResponse.Model,
Cached: false,
ModelResponse: schemas.ModelResponse{
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/anthropic/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const (
providerName = "anthropic"
ProviderID = "anthropic"
)

// Client is a client for accessing OpenAI API
Expand Down Expand Up @@ -54,7 +54,7 @@ func NewClient(providerConfig *Config, clientConfig *clients.ClientConfig, tel *
}

func (c *Client) Provider() string {
return providerName
return ProviderID
}

func (c *Client) ModelName() string {
Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/anthropic/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package anthropic

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 OpenAI-specific model params with the specific validation of values
Expand Down Expand Up @@ -57,6 +60,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/anthropic/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package anthropic

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

func init() {
provider.LangRegistry.Register(ProviderID, &Config{})
}

0 comments on commit d1cb962

Please sign in to comment.