Skip to content

Commit

Permalink
Support custom temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
leafduo committed Mar 4, 2023
1 parent dbc8c84 commit b8bc63b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ go install github.com/leafduo/chatgpt-telegram-bot@latest
```bash
export OPENAI_API_KEY=<your_openai_api_key>
export TELEGRAM_APITOKEN=<your_telegram_bot_token>
export ALLOWED_TELEGRAM_ID=<your_telegram_id>,<your_friend_telegram_id>
export ALLOWED_TELEGRAM_ID=<your_telegram_id>,<your_friend_telegram_id> # optional, default is empty. Only allow these users to use the bot. Empty means allow all users.
export MODEL_TEMPERATURE=1.0 # optional, default is 1.0. Higher temperature means more random responses. See https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature

chatgpt-telegram-bot
```
```
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
var cfg struct {
TelegramAPIToken string `env:"TELEGRAM_APITOKEN"`
OpenAIAPIKey string `env:"OPENAI_API_KEY"`
ModelTemperature float32 `env:"MODEL_TEMPERATURE" envDefault:"1.0"`
AllowedTelegramID []int64 `env:"ALLOWED_TELEGRAM_ID" envSeparator:","`
}

Expand Down Expand Up @@ -165,7 +166,7 @@ func handleUserPrompt(userID int64, msg string) (string, bool, error) {

req := gogpt.ChatCompletionRequest{
Model: gogpt.GPT3Dot5Turbo,
Temperature: 1,
Temperature: cfg.ModelTemperature,
TopP: 1,
N: 1,
// PresencePenalty: 0.2,
Expand Down

0 comments on commit b8bc63b

Please sign in to comment.