Skip to content

Commit 70f1207

Browse files
authored
💥 Convert all camelCase config fields to the snake_case in the provider configs (#260)
1 parent 3fa5b45 commit 70f1207

File tree

8 files changed

+26
-23
lines changed

8 files changed

+26
-23
lines changed

pkg/providers/anthropic/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
3636
}
3737

3838
type Config struct {
39-
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
40-
APIVersion string `yaml:"apiVersion" json:"apiVersion" validate:"required"`
41-
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
39+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
40+
APIVersion string `yaml:"api_version" json:"api_version" validate:"required"`
41+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
4242
Model string `yaml:"model" json:"model" validate:"required"`
4343
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
44-
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
44+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
4545
}
4646

4747
// DefaultConfig for OpenAI models

pkg/providers/azureopenai/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type Params struct {
2020
Tools []string `yaml:"tools,omitempty" json:"tools"`
2121
ToolChoice interface{} `yaml:"tool_choice,omitempty" json:"tool_choice"`
2222
ResponseFormat interface{} `yaml:"response_format,omitempty" json:"response_format"` // TODO: should this be a part of the chat request API?
23-
// Stream bool `json:"stream,omitempty"` // TODO: we are not supporting this at the moment
2423
}
2524

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

4544
type Config struct {
46-
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required"` // The name of your Azure OpenAI Resource (e.g https://glide-test.openai.azure.com/)
47-
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint"`
45+
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/)
46+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint"`
4847
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)
4948
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)
5049
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
51-
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`
50+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
5251
}
5352

5453
// DefaultConfig for OpenAI models

pkg/providers/bedrock/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
3131
}
3232

3333
type Config struct {
34-
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
35-
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
34+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
35+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
3636
Model string `yaml:"model" json:"model" validate:"required"`
3737
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
3838
AccessKey string `yaml:"access_key" json:"-" validate:"required"`
3939
SecretKey string `yaml:"secret_key" json:"-" validate:"required"`
4040
AWSRegion string `yaml:"aws_region" json:"awsRegion" validate:"required"`
41-
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
41+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
4242
}
4343

4444
// DefaultConfig for OpenAI models

pkg/providers/cohere/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
3939
}
4040

4141
type Config struct {
42-
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required,http_url"`
43-
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint" validate:"required"`
42+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required,http_url"`
43+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
4444
Model string `yaml:"model" json:"model" validate:"required"` // https://docs.cohere.com/docs/models#command
4545
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
4646
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`

pkg/providers/octoml/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type Params struct {
1313
StopWords []string `yaml:"stop,omitempty" json:"stop"`
1414
FrequencyPenalty int `yaml:"frequency_penalty,omitempty" json:"frequency_penalty"`
1515
PresencePenalty int `yaml:"presence_penalty,omitempty" json:"presence_penalty"`
16-
// Stream bool `json:"stream,omitempty"` // TODO: we are not supporting this at the moment
1716
}
1817

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

3635
type Config struct {
37-
BaseURL string `yaml:"base_url" json:"baseUrl" validate:"required"`
38-
ChatEndpoint string `yaml:"chat_endpoint" json:"chatEndpoint" validate:"required"`
36+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
37+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
3938
Model string `yaml:"model" json:"model" validate:"required"`
4039
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
41-
DefaultParams *Params `yaml:"default_params,omitempty" json:"defaultParams"`
40+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
4241
}
4342

4443
// DefaultConfig for OctoML models

pkg/providers/ollama/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
4040
}
4141

4242
type Config struct {
43-
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
44-
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
43+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
44+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
4545
Model string `yaml:"model" json:"model" validate:"required"`
46-
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
46+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
4747
}
4848

4949
// DefaultConfig for OpenAI models

pkg/providers/openai/chat.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
116116
// Parse the response JSON
117117
var chatCompletion ChatCompletion
118118

119+
c.logger.Debug(
120+
"Raw chat response",
121+
zap.ByteString("resp", bodyBytes),
122+
)
123+
119124
err = json.Unmarshal(bodyBytes, &chatCompletion)
120125
if err != nil {
121126
c.logger.Error(

pkg/providers/openai/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func (p *Params) UnmarshalYAML(unmarshal func(interface{}) error) error {
4242
}
4343

4444
type Config struct {
45-
BaseURL string `yaml:"baseUrl" json:"baseUrl" validate:"required"`
46-
ChatEndpoint string `yaml:"chatEndpoint" json:"chatEndpoint" validate:"required"`
45+
BaseURL string `yaml:"base_url" json:"base_url" validate:"required"`
46+
ChatEndpoint string `yaml:"chat_endpoint" json:"chat_endpoint" validate:"required"`
4747
Model string `yaml:"model" json:"model" validate:"required"`
4848
APIKey fields.Secret `yaml:"api_key" json:"-" validate:"required"`
49-
DefaultParams *Params `yaml:"defaultParams,omitempty" json:"defaultParams"`
49+
DefaultParams *Params `yaml:"default_params,omitempty" json:"default_params"`
5050
}
5151

5252
// DefaultConfig for OpenAI models

0 commit comments

Comments
 (0)