Skip to content

Commit

Permalink
#29: init logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger12 committed Dec 27, 2023
1 parent 98c029d commit a4b41f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/providers/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"

"glide/pkg/providers"

"glide/pkg/telemetry"
)

const (
Expand All @@ -24,6 +26,7 @@ const (
type ProviderClient struct {
BaseURL string `json:"baseURL"`
HTTPClient *http.Client `json:"httpClient"`
Telemetry *telemetry.Telemetry `json:"telemetry"`
}

// ChatRequest is a request to complete a chat completion..
Expand Down Expand Up @@ -92,7 +95,7 @@ type ChatResponse struct {
func (c *ProviderClient) Chat(u *providers.UnifiedAPIData) (*ChatResponse, error) {
// Create a new chat request

slog.Info("creating chat request")
c.Telemetry.Logger.Info("creating new chat request")

chatRequest := CreateChatRequest(u)

Expand Down
12 changes: 12 additions & 0 deletions pkg/providers/openai/openaiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"errors"

"glide/pkg/providers"

"glide/pkg/telemetry"
)

const (
Expand All @@ -30,10 +32,20 @@ var (
// - *Client: A pointer to the created client.
// - error: An error if the client creation failed.
func Client() (*ProviderClient, error) {

tel, err := telemetry.NewTelemetry(&telemetry.Config{LogConfig: telemetry.NewLogConfig()})
if err != nil {
return nil, err
}

tel.Logger.Info("init openai provider client")


// Create a new client
c := &ProviderClient{
BaseURL: defaultBaseURL,
HTTPClient: providers.HTTPClient,
Telemetry: tel,
}

return c, nil
Expand Down

0 comments on commit a4b41f0

Please sign in to comment.