From 1b8d63ddb4553e2cc2d7fadf76d62acb367f9977 Mon Sep 17 00:00:00 2001 From: Dmitry Rubtsov Date: Mon, 28 Aug 2023 18:51:53 +0600 Subject: [PATCH] small fixes --- cmd/matrix-gpt/main.go | 4 ++-- internal/bot/handlers.go | 2 ++ internal/bot/strings.go | 3 ++- internal/gpt/completions.go | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/matrix-gpt/main.go b/cmd/matrix-gpt/main.go index 57c2aad..61bb3b0 100644 --- a/cmd/matrix-gpt/main.go +++ b/cmd/matrix-gpt/main.go @@ -69,13 +69,13 @@ func main() { Name: "gpt-timeout", Usage: "Time to wait for a GPT response (in seconds)", EnvVars: []string{"GPT_TIMEOUT"}, - Value: 35, + Value: 60, }, &cli.IntFlag{ Name: "max-attempts", Usage: "Maximum number of attempts for GPT requests", EnvVars: []string{"MAX_ATTEMPTS"}, - Value: 1, + Value: 3, }, &cli.StringSliceFlag{ Name: "user-ids", diff --git a/internal/bot/handlers.go b/internal/bot/handlers.go index a1eb5cb..b953853 100644 --- a/internal/bot/handlers.go +++ b/internal/bot/handlers.go @@ -122,6 +122,8 @@ func (b *Bot) err(evt *event.Event, err error) { default: if errors.Is(err, context.DeadlineExceeded) { b.markdownResponse(evt, true, timeoutMsg) + } else { + b.reactionResponse(evt, "❌") } } } diff --git a/internal/bot/strings.go b/internal/bot/strings.go index 1cc1947..27ed0f0 100644 --- a/internal/bot/strings.go +++ b/internal/bot/strings.go @@ -9,7 +9,8 @@ const ( **Notes** - You can use the first letter of a command as an alias. For example, "!i" for "!image". - If you wish to terminate the current processing, simply delete your message from the chat. +- The bot responds with ❌ reaction if there are any errors. Contact the administrator if you see this. ` timeoutMsg = "Timeout error. Please try again. If issue persists, contact the administrator." - unknownCommandMsg = "Unknown command. Please use the `!help` command to access the available commands" + unknownCommandMsg = "Unknown command. Please use the `!help` command to access the available commands." ) diff --git a/internal/gpt/completions.go b/internal/gpt/completions.go index 38a128f..1a5f057 100644 --- a/internal/gpt/completions.go +++ b/internal/gpt/completions.go @@ -61,7 +61,7 @@ func (g *Gpt) createCompletionWithTimeout(ctx context.Context, msg []openai.Chat continue } - time.Sleep(time.Duration(i*2) * time.Second) + time.Sleep(time.Duration(i*3) * time.Second) } return openai.ChatCompletionResponse{}, err