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

openai: add make it possible to set the "user" in the gpt completion call #495

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions command/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func CallChatGPT(cfg Config, inputMessages []ChatMessage, stream bool) (<-chan s
Temperature: cfg.Temperature,
Seed: cfg.Seed,
MaxTokens: cfg.MaxTokens,
User: cfg.APILogUser,
Stream: stream,
Messages: inputMessages,
})
Expand Down
9 changes: 9 additions & 0 deletions command/openai/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openai

import (
"os"
"time"

"github.com/innogames/slack-bot/v2/bot/config"
Expand All @@ -27,6 +28,10 @@ type Config struct {

// log all input+output text to the logger. This could include personal information, therefore disabled by default!
LogTexts bool `mapstructure:"log_texts"`

// user name to identify the bot which should be part of the OpenAI usage statistics.
// use {hostname} to set the hostname of the machine
APILogUser string `mapstructure:"api_log_user"`
}

// IsEnabled checks if token is set
Expand All @@ -46,5 +51,9 @@ func loadConfig(config *config.Config) Config {
cfg := defaultConfig
_ = config.LoadCustom("openai", &cfg)

if cfg.APILogUser == "{hostname}" {
cfg.APILogUser, _ = os.Hostname()
}

return cfg
}
Loading