Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 Convert all camelCase config fields to the snake_case in the provider configs #260

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/providers/anthropic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
APIVersion string `yaml:"apiVersion" json:"apiVersion" validate:"required"`
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
APIVersion string `yaml:"api_version" json:"api_version" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"`
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OpenAI models
Expand Down
7 changes: 3 additions & 4 deletions pkg/providers/azureopenai/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Params struct {
Tools []string `yaml:"tools,omitempty" json:"tools"`
ToolChoice interface{} `yaml:"tool_choice,omitempty" json:"tool_choice"`
ResponseFormat interface{} `yaml:"response_format,omitempty" json:"response_format"` // TODO: should this be a part of the chat request API?
// Stream bool `json:"stream,omitempty"` // TODO: we are not supporting this at the moment
}

func DefaultParams() Params {
Expand All @@ -43,12 +42,12 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required"` // The name of your Azure OpenAI Resource (e.g https://glide-test.openai.azure.com/)
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"` // The name of your Azure OpenAI Resource (e.g https://glide-test.openai.azure.com/)
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint"`
Model string `yaml:"model" json:"model" validate:"required"` // This is your deployment name. You're required to first deploy a model before you can make calls (e.g. glide-gpt-35)
APIVersion string `yaml:"api_version" json:"apiVersion" validate:"required"` // The API version to use for this operation. This follows the YYYY-MM-DD format (e.g 2023-05-15)
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OpenAI models
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/bedrock/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"`
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
AccessKey string `yaml:"access_key" json:"-" validate:"required"`
SecretKey string `yaml:"secret_key" json:"-" validate:"required"`
AWSRegion string `yaml:"aws_region" json:"awsRegion" validate:"required"`
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OpenAI models
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/cohere/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required,http_url"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required,http_url"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"` // https://docs.cohere.com/docs/models#command
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`
Expand Down
7 changes: 3 additions & 4 deletions pkg/providers/octoml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Params struct {
StopWords []string `yaml:"stop,omitempty" json:"stop"`
FrequencyPenalty int `yaml:"frequency_penalty,omitempty" json:"frequency_penalty"`
PresencePenalty int `yaml:"presence_penalty,omitempty" json:"presence_penalty"`
// Stream bool `json:"stream,omitempty"` // TODO: we are not supporting this at the moment
}

func DefaultParams() Params {
Expand All @@ -34,11 +33,11 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"`
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OctoML models
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/ollama/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"`
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OpenAI models
Expand Down
5 changes: 5 additions & 0 deletions pkg/providers/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
// Parse the response JSON
var chatCompletion ChatCompletion

c.logger.Debug(
"Raw chat response",
zap.ByteString("resp", bodyBytes),
)

err = json.Unmarshal(bodyBytes, &chatCompletion)
if err != nil {
c.logger.Error(
Expand Down
6 changes: 3 additions & 3 deletions pkg/providers/openai/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
}

type Config struct {
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
Model string `yaml:"model" json:"model" validate:"required"`
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
}

// DefaultConfig for OpenAI models
Expand Down
Loading