From f7ebee8fb03f21a4dbb9b3719489a2f212de7088 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sun, 22 Jun 2025 10:28:19 +0300 Subject: [PATCH] Enha: simplier guesser prompt --- llmapi/main.go | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/llmapi/main.go b/llmapi/main.go index 21b0f79..4d8c383 100644 --- a/llmapi/main.go +++ b/llmapi/main.go @@ -23,7 +23,8 @@ var ( // got prompt: control character (\\u0000-\\u001F) found while parsing a string at line 4 column 0 MimePrompt = `we are playing alias;\nyou are a mime (player who gives a clue of one noun word and number of cards you expect them to open) of the %s team (people who would guess by your clue want open the %s cards);\nplease return your clue, number of cards to open and what words you mean them to find using that clue in json like:\n{\n\"clue\": \"one-word-noun\",\n\"number\": \"number-from-0-to-9\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the game info in json:\n%s` // TODO: simplify; bot gets confused; so show it only unrevealed cards and last clue (maybe older clues as well); - GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s` + GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (you want open %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nthe team who openes all their cards first wins.\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;\nhere is the cards (and other info), you need to choose revealed==false words:\n%s` + GuesserSimplePrompt = `we are playing game of alias;\n you were given a clue: \"%s\";\nnumber of words you can open with that clue is:%s;\nplease return your guesses and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guesses\": [\"word1\", \"word2\", ...],\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that left:\n%s` ) type DSResp struct { @@ -352,6 +353,13 @@ func saveRoom(room *models.Room) error { return nil } +func (b *Bot) BuildSimpleGuesserPrompt(room *models.Room) string { + clue := room.ActionHistory[len(room.ActionHistory)-1].Word + number := room.ActionHistory[len(room.ActionHistory)-1].Number + words := make([]string, len(room.Cards)) + return fmt.Sprintf(GuesserSimplePrompt, clue, number, words) +} + func (b *Bot) BuildPrompt(room *models.Room) string { if b.Role == "" { return "" @@ -363,16 +371,16 @@ func (b *Bot) BuildPrompt(room *models.Room) string { if b.Role == models.UserRoleMime { toText["cards"] = room.Cards } - if b.Role == models.UserRoleGuesser { - copiedCards := make([]models.WordCard, len(room.Cards)) - copy(copiedCards, room.Cards) - for i, card := range copiedCards { - if !card.Revealed { - copiedCards[i].Color = models.WordColorUknown - } - } - toText["cards"] = copiedCards - } + // if b.Role == models.UserRoleGuesser { + // copiedCards := make([]models.WordCard, len(room.Cards)) + // copy(copiedCards, room.Cards) + // for i, card := range copiedCards { + // if !card.Revealed { + // copiedCards[i].Color = models.WordColorUknown + // } + // } + // toText["cards"] = copiedCards + // } data, err := json.Marshal(toText) if err != nil { b.log.Error("failed to marshal", "error", err) @@ -384,7 +392,8 @@ func (b *Bot) BuildPrompt(room *models.Room) string { return fmt.Sprintf(MimePrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) } if b.Role == models.UserRoleGuesser { - return fmt.Sprintf(GuesserPrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) + // return fmt.Sprintf(GuesserPrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) + return b.BuildSimpleGuesserPrompt(room) } return "" }