Skip to content

Commit

Permalink
feat: unify aiClientName const for all providers (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthisholleville committed Jan 7, 2024
1 parent ce4910b commit 5c17c24
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 15 deletions.
4 changes: 3 additions & 1 deletion pkg/ai/amazonbedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/aws/aws-sdk-go/service/bedrockruntime"
)

const amazonbedrockAIClientName = "amazonbedrock"

// AmazonBedRockClient represents the client for interacting with the Amazon Bedrock service.
type AmazonBedRockClient struct {
nopCloser
Expand Down Expand Up @@ -147,5 +149,5 @@ func (a *AmazonBedRockClient) GetCompletion(ctx context.Context, prompt string)

// GetName returns the name of the AmazonBedRockClient.
func (a *AmazonBedRockClient) GetName() string {
return "amazonbedrock"
return amazonbedrockAIClientName
}
4 changes: 3 additions & 1 deletion pkg/ai/amazonsagemaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/aws/aws-sdk-go/service/sagemakerruntime"
)

const amazonsagemakerAIClientName = "amazonsagemaker"

type SageMakerAIClient struct {
nopCloser

Expand Down Expand Up @@ -131,5 +133,5 @@ func (c *SageMakerAIClient) GetCompletion(_ context.Context, prompt string) (str
}

func (c *SageMakerAIClient) GetName() string {
return "amazonsagemaker"
return amazonsagemakerAIClientName
}
4 changes: 3 additions & 1 deletion pkg/ai/azureopenai.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/sashabaranov/go-openai"
)

const azureAIClientName = "azureopenai"

type AzureAIClient struct {
nopCloser

Expand Down Expand Up @@ -58,5 +60,5 @@ func (c *AzureAIClient) GetCompletion(ctx context.Context, prompt string) (strin
}

func (c *AzureAIClient) GetName() string {
return "azureopenai"
return azureAIClientName
}
6 changes: 4 additions & 2 deletions pkg/ai/cohere.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import (
"github.com/cohere-ai/cohere-go"
)

const cohereAIClientName = "cohere"

type CohereClient struct {
nopCloser

client *cohere.Client
model string
temperature float32
Expand Down Expand Up @@ -68,5 +70,5 @@ func (c *CohereClient) GetCompletion(_ context.Context, prompt string) (string,
}

func (c *CohereClient) GetName() string {
return "cohere"
return cohereAIClientName
}
14 changes: 7 additions & 7 deletions pkg/ai/iai.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ var (
&GoogleGenAIClient{},
}
Backends = []string{
"openai",
"localai",
"azureopenai",
"cohere",
"amazonbedrock",
"amazonsagemaker",
openAIClientName,
localAIClientName,
azureAIClientName,
cohereAIClientName,
amazonbedrockAIClientName,
amazonsagemakerAIClientName,
googleAIClientName,
"noopai",
noopAIClientName,
}
)

Expand Down
4 changes: 3 additions & 1 deletion pkg/ai/localai.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ai

const localAIClientName = "localai"

type LocalAIClient struct {
OpenAIClient
}

func (a *LocalAIClient) GetName() string {
return "localai"
return localAIClientName
}
4 changes: 3 additions & 1 deletion pkg/ai/noopai.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"context"
)

const noopAIClientName = "noopai"

type NoOpAIClient struct {
nopCloser
}
Expand All @@ -31,5 +33,5 @@ func (c *NoOpAIClient) GetCompletion(_ context.Context, prompt string) (string,
}

func (c *NoOpAIClient) GetName() string {
return "noopai"
return noopAIClientName
}
4 changes: 3 additions & 1 deletion pkg/ai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/sashabaranov/go-openai"
)

const openAIClientName = "openai"

type OpenAIClient struct {
nopCloser

Expand Down Expand Up @@ -78,5 +80,5 @@ func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string) (string
}

func (c *OpenAIClient) GetName() string {
return "openai"
return openAIClientName
}

0 comments on commit 5c17c24

Please sign in to comment.