Skip to content

Commit

Permalink
breaking: env config now sets model name, not ver
Browse files Browse the repository at this point in the history
  • Loading branch information
iamwavecut committed Nov 7, 2023
1 parent d9970bc commit 4e02594
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You will need to provide the following arguments to the build command:
docker build -t telegram-chatgpt-bot . \
--build-arg OPENAI_TOKEN=<required, your_api_token> \
--build-arg BOT_TOKEN=<required, your_bot_token> \
--build-arg CHATGPT_VERSION=<optional, 3.5 | 4>
--build-arg CHAT_MODEL=<optional, defaults to 'gpt-3.5-turbo-1106'>
```

You can also run the bot locally
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Config struct {
TelegramAPIToken string `env:"BOT_TOKEN,required"`
OpenAIToken string `env:"OPENAI_TOKEN,required"`
DefaultLanguage string `env:"LANG,default=en"`
ChatGPTVersion string `env:"CHATGPT_VERSION,default=3.5"`
ChatModel string `env:"CHAT_MODEL,default=gpt-3.5-turbo-1106"`
}

var (
Expand Down
9 changes: 1 addition & 8 deletions internal/handlers/private.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ func apiRequestRoutine(
const (
chatGPT4 = "4"

Check failure on line 106 in internal/handlers/private.go

View workflow job for this annotation

GitHub Actions / lint

const `chatGPT4` is unused (unused)
)
var modelVersion string
switch config.Get().ChatGPTVersion {
case chatGPT4:
modelVersion = openai.GPT4
default:
modelVersion = openai.GPT3Dot5Turbo
}

instruction := openai.ChatCompletionMessage{
Role: "system",
Expand Down Expand Up @@ -160,7 +153,7 @@ func apiRequestRoutine(
resp, err := openaiClient.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: modelVersion,
Model: config.Get().ChatModel,
Messages: append([]openai.ChatCompletionMessage{instruction}, chatHistory...),
MaxTokens: openAIMaxTokens,
Temperature: openAITemperature,
Expand Down

0 comments on commit 4e02594

Please sign in to comment.