This commit is contained in:
2026-02-12 14:01:43 +03:00
parent e5a3b6253d
commit ee6729e12a
8 changed files with 36 additions and 48 deletions

View File

@@ -14,6 +14,7 @@ import (
"git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea"
"git.nix13.pw/scuroneko/laniakea/tgapi"
"github.com/google/uuid"
)
@@ -415,7 +416,7 @@ func newChatStage2(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
selectedScenariosIds := make(extypes.Slice[int], 0)
if len(ctx.Args) > 1 {
selectedScenariosIds = utils.Map(utils.StringToInt, ctx.Args[1:])
selectedScenariosIds = utils.Map(ctx.Args[1:], utils.StringToInt)
}
out := []string{
@@ -489,7 +490,7 @@ func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
chatPrompt = "Вот краткое описание мира(сеттинг): " + scenario.Prompt + "."
}
scenariosIds := utils.Map(utils.StringToInt, ctx.Args[1:])
scenariosIds := utils.Map(ctx.Args[1:], utils.StringToInt)
if len(scenariosIds) > 0 && scenariosIds[0] > 0 {
rep := psql.NewRPRepository(db)
var scenariosPrompt []string
@@ -522,7 +523,7 @@ func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
if err != nil {
ctx.Error(err)
}
err = redisRpRep.SetChatScenariosIDs(ctx.FromID, waifuId, strings.Join(utils.Map(utils.AnyToString, scenariosIds), ","))
err = redisRpRep.SetChatScenariosIDs(ctx.FromID, waifuId, strings.Join(utils.Map(scenariosIds, utils.AnyToString), ","))
if err != nil {
ctx.Error(err)
}
@@ -650,7 +651,7 @@ func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
kb := laniakea.NewInlineKeyboard(1)
kb.AddCallbackButtonStyle("Отменить", laniakea.ButtonStyleDanger, "rp.cancel")
m := ctx.Keyboard("Генерация запущена...", kb)
ctx.SendAction(laniakea.ChatActionTyping)
ctx.SendAction(tgapi.ChatActionTyping)
api := ai.NewOpenAIAPI(ai.GPTBaseUrl, "", rpUser.Model.Key)
defer api.Close()
res, err := api.CreateCompletion(messages, userMessage, 1.0)
@@ -718,6 +719,7 @@ func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
ctx.AnswerCbQueryText("Запущена повторная генерация…")
ctx.EditCallback("Генерация запущена...", nil)
redRep := red.NewRPRepository(db)
waifuId := redRep.GetSelectedWaifu(ctx.FromID)
@@ -780,7 +782,7 @@ func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext)
}
kb := laniakea.NewInlineKeyboard(1)
kb.AddCallbackButton("🔄Перегенерировать", "rp.regenerate", count)
kb.AddCallbackButtonStyle("🔄 Перегенерировать 🔄", laniakea.ButtonStyleDanger, "rp.regenerate", count)
ctx.EditCallback(laniakea.EscapeMarkdown(res.Choices[0].Message.Content), kb)
}