feat: unify aiClientName const for all providers (#848)

This commit is contained in:
Matthis
2024-01-07 13:01:15 +01:00
committed by GitHub
parent ce4910bc5d
commit 5c17c24055
8 changed files with 29 additions and 15 deletions

View File

@@ -10,6 +10,8 @@ import (
"github.com/aws/aws-sdk-go/service/bedrockruntime" "github.com/aws/aws-sdk-go/service/bedrockruntime"
) )
const amazonbedrockAIClientName = "amazonbedrock"
// AmazonBedRockClient represents the client for interacting with the Amazon Bedrock service. // AmazonBedRockClient represents the client for interacting with the Amazon Bedrock service.
type AmazonBedRockClient struct { type AmazonBedRockClient struct {
nopCloser nopCloser
@@ -147,5 +149,5 @@ func (a *AmazonBedRockClient) GetCompletion(ctx context.Context, prompt string)
// GetName returns the name of the AmazonBedRockClient. // GetName returns the name of the AmazonBedRockClient.
func (a *AmazonBedRockClient) GetName() string { func (a *AmazonBedRockClient) GetName() string {
return "amazonbedrock" return amazonbedrockAIClientName
} }

View File

@@ -23,6 +23,8 @@ import (
"github.com/aws/aws-sdk-go/service/sagemakerruntime" "github.com/aws/aws-sdk-go/service/sagemakerruntime"
) )
const amazonsagemakerAIClientName = "amazonsagemaker"
type SageMakerAIClient struct { type SageMakerAIClient struct {
nopCloser nopCloser
@@ -131,5 +133,5 @@ func (c *SageMakerAIClient) GetCompletion(_ context.Context, prompt string) (str
} }
func (c *SageMakerAIClient) GetName() string { func (c *SageMakerAIClient) GetName() string {
return "amazonsagemaker" return amazonsagemakerAIClientName
} }

View File

@@ -7,6 +7,8 @@ import (
"github.com/sashabaranov/go-openai" "github.com/sashabaranov/go-openai"
) )
const azureAIClientName = "azureopenai"
type AzureAIClient struct { type AzureAIClient struct {
nopCloser nopCloser
@@ -58,5 +60,5 @@ func (c *AzureAIClient) GetCompletion(ctx context.Context, prompt string) (strin
} }
func (c *AzureAIClient) GetName() string { func (c *AzureAIClient) GetName() string {
return "azureopenai" return azureAIClientName
} }

View File

@@ -20,9 +20,11 @@ import (
"github.com/cohere-ai/cohere-go" "github.com/cohere-ai/cohere-go"
) )
const cohereAIClientName = "cohere"
type CohereClient struct { type CohereClient struct {
nopCloser nopCloser
client *cohere.Client client *cohere.Client
model string model string
temperature float32 temperature float32
@@ -68,5 +70,5 @@ func (c *CohereClient) GetCompletion(_ context.Context, prompt string) (string,
} }
func (c *CohereClient) GetName() string { func (c *CohereClient) GetName() string {
return "cohere" return cohereAIClientName
} }

View File

@@ -29,14 +29,14 @@ var (
&GoogleGenAIClient{}, &GoogleGenAIClient{},
} }
Backends = []string{ Backends = []string{
"openai", openAIClientName,
"localai", localAIClientName,
"azureopenai", azureAIClientName,
"cohere", cohereAIClientName,
"amazonbedrock", amazonbedrockAIClientName,
"amazonsagemaker", amazonsagemakerAIClientName,
googleAIClientName, googleAIClientName,
"noopai", noopAIClientName,
} }
) )

View File

@@ -1,9 +1,11 @@
package ai package ai
const localAIClientName = "localai"
type LocalAIClient struct { type LocalAIClient struct {
OpenAIClient OpenAIClient
} }
func (a *LocalAIClient) GetName() string { func (a *LocalAIClient) GetName() string {
return "localai" return localAIClientName
} }

View File

@@ -17,6 +17,8 @@ import (
"context" "context"
) )
const noopAIClientName = "noopai"
type NoOpAIClient struct { type NoOpAIClient struct {
nopCloser nopCloser
} }
@@ -31,5 +33,5 @@ func (c *NoOpAIClient) GetCompletion(_ context.Context, prompt string) (string,
} }
func (c *NoOpAIClient) GetName() string { func (c *NoOpAIClient) GetName() string {
return "noopai" return noopAIClientName
} }

View File

@@ -20,6 +20,8 @@ import (
"github.com/sashabaranov/go-openai" "github.com/sashabaranov/go-openai"
) )
const openAIClientName = "openai"
type OpenAIClient struct { type OpenAIClient struct {
nopCloser nopCloser
@@ -78,5 +80,5 @@ func (c *OpenAIClient) GetCompletion(ctx context.Context, prompt string) (string
} }
func (c *OpenAIClient) GetName() string { func (c *OpenAIClient) GetName() string {
return "openai" return openAIClientName
} }