Skip to content

Commit

Permalink
#29: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger12 committed Dec 20, 2023
1 parent 519128e commit 1d48263
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions pkg/providers/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import (
"net/http"
"reflect"
"strings"

"github.com/cloudwego/hertz/pkg/protocol"
"github.com/cloudwego/hertz/pkg/protocol/consts"
)

const (
Expand Down Expand Up @@ -169,7 +166,7 @@ func (c *Client) CreateChatResponse(ctx context.Context, r *ChatRequest) (*ChatR
}
}

resp, err := c.createChatHttp(ctx, r)
resp, err := c.createChatHttp(r)
if err != nil {
return nil, err
}
Expand All @@ -178,7 +175,7 @@ func (c *Client) CreateChatResponse(ctx context.Context, r *ChatRequest) (*ChatR
}
return resp, nil
}

/* will remove later
func (c *Client) createChatHertz(ctx context.Context, payload *ChatRequest) (*ChatResponse, error) {
slog.Info("running createChat")
Expand All @@ -201,7 +198,7 @@ func (c *Client) createChatHertz(ctx context.Context, payload *ChatRequest) (*Ch
req.Header.SetMethod(consts.MethodPost)
req.SetRequestURI(c.buildURL("/chat/completions", c.Provider.Model))
req.SetBody(payloadBytes)
req.Header.Set("Authorization", "Bearer "+c.Provider.ApiKey)
req.Header.Set("Authorization", "Bearer "+c.Provider.APIKey)
req.Header.Set("Content-Type", "application/json")
slog.Info("making request")
Expand Down Expand Up @@ -230,8 +227,9 @@ func (c *Client) createChatHertz(ctx context.Context, payload *ChatRequest) (*Ch
var response ChatResponse
return &response, json.NewDecoder(bytes.NewReader(res.Body())).Decode(&response)
}
*/

func (c *Client) createChatHttp(ctx context.Context, payload *ChatRequest) (*ChatResponse, error) {
func (c *Client) createChatHttp(payload *ChatRequest) (*ChatResponse, error) {

Check warning on line 232 in pkg/providers/openai/chat.go

View workflow job for this annotation

GitHub Actions / Static Checks

var-naming: method createChatHttp should be createChatHTTP (revive)
slog.Info("running createChatHttp")

if payload.StreamingFunc != nil {
Expand All @@ -255,7 +253,7 @@ func (c *Client) createChatHttp(ctx context.Context, payload *ChatRequest) (*Cha
return nil, err
}

req.Header.Set("Authorization", "Bearer "+c.Provider.ApiKey)
req.Header.Set("Authorization", "Bearer "+c.Provider.APIKey)
req.Header.Set("Content-Type", "application/json")

httpClient := &http.Client{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/openai/openaiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ func (c *Client) NewClient(poolName string, modelName string) (*Client, error) {
Provider: *selectedProvider,
organization: defaultOrganization,
apiType: APITypeOpenAI,
httpClient: HttpClient(),
httpClient: HTTPClient(),
}

return client, nil
}

func HttpClient() *client.Client {
func HTTPClient() *client.Client {
c, err := client.NewClient()
if err != nil {
slog.Error(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Pool struct {
type Provider struct {
Provider string `yaml:"provider"`
Model string `yaml:"model"`
ApiKey string `yaml:"api_key"`
APIKey string `yaml:"api_key"`
TimeoutMs int `yaml:"timeout_ms,omitempty"`
DefaultParams map[string]interface{} `yaml:"default_params,omitempty"`
}
Expand Down

0 comments on commit 1d48263

Please sign in to comment.