diff --git a/bot.go b/bot.go index 1d128ec..a808480 100644 --- a/bot.go +++ b/bot.go @@ -85,7 +85,7 @@ func logMiddleware(next tele.HandlerFunc) tele.HandlerFunc { return func(c tele.Context) error { upd := c.Update() defer func() { - logger.Debugw("Log middleware", "update", upd) + logger.Infow("Log middleware", "update", upd) }() return next(c) diff --git a/botcmd_translate.go b/botcmd_translate.go index e83e49f..82a38b2 100644 --- a/botcmd_translate.go +++ b/botcmd_translate.go @@ -4,7 +4,6 @@ import ( "regexp" "strings" - "github.com/samber/lo" tele "gopkg.in/telebot.v3" "git.gensokyo.cafe/kkyy/tgbot_misaka_5882f7/openai" @@ -49,6 +48,7 @@ func handleTranslateCmd(c tele.Context) error { tele.Silent, ) } + logger.Infof("trimmed message: %q", payload) _, err := c.Bot().Reply(msg, "Sure. To what language?", tele.Silent, translateMenu) return err @@ -91,7 +91,6 @@ func handleTranslateBtn(c tele.Context) error { Content: payload, }, }, - Temperature: lo.ToPtr(0.6), } resp, err := ai.ChatCompletion(req) diff --git a/cfg.go b/cfg.go index ce9efca..15a34e4 100644 --- a/cfg.go +++ b/cfg.go @@ -10,7 +10,6 @@ import ( ) type ConfigDef struct { - LogLevel string `env:"TG_LOG_LEVEL" env-default:"info"` AdminUIDs []int64 `env:"TG_ADMIN_UIDS"` TGBotToken string `env:"TG_TOKEN" env-required:""` TGAnnounceCommands bool `env:"TG_ANNOUNCE_CMDS"` diff --git a/main.go b/main.go index 94df370..d8fab53 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "time" "go.uber.org/zap" - "go.uber.org/zap/zapcore" tele "gopkg.in/telebot.v3" "git.gensokyo.cafe/kkyy/mycurrencynet" @@ -15,13 +14,9 @@ import ( ) var logger *zap.SugaredLogger -var loglvl zap.AtomicLevel func initLogger() { - logCfg := zap.NewProductionConfig() - loglvl = logCfg.Level - - l, err := logCfg.Build() + l, err := zap.NewProduction() if err != nil { panic(err) } @@ -94,12 +89,6 @@ func main() { if err := LoadCfg(); err != nil { logger.Fatalw("Failed to load config", "err", err) } - parsedLvl, err := zapcore.ParseLevel(config.LogLevel) - if err != nil { - logger.Warnf("Invalid log level %q", config.LogLevel) - } else { - loglvl.SetLevel(parsedLvl) - } runBot() } diff --git a/openai/prompts/prompts.go b/openai/prompts/prompts.go index d0e74df..43f5ef5 100644 --- a/openai/prompts/prompts.go +++ b/openai/prompts/prompts.go @@ -1,9 +1,6 @@ package prompts -import ( - "fmt" - "strings" -) +import "fmt" func General() string { return "You are a helpful assistant." @@ -11,14 +8,7 @@ func General() string { func Translate(targetLang string) string { return fmt.Sprintf( - strings.Join([]string{ - "You are a helpful assistant.", - "Your task is to help translate the text sent by the user into %s.", - "You should never interpret the user's text, but only translate it.", - "You should structure the translated text to sound natural in native %s while keeping the meanings unchanged.", - "If the user's text contains only a single word, please also add a brief explanation in %s, of the meaning of the original word.", - "The first text to be translated is:", - }, " \n"), - targetLang, targetLang, targetLang, + "You are a helpful assistant. Your task is to help translate the following text to %s. You should not interpret the text. You should structure the translated text to look natural in native %s, while keeping the meaning unchanged.", + targetLang, targetLang, ) }