Feat: ru prompts for llm
This commit is contained in:
		| @@ -25,10 +25,10 @@ var ( | ||||
| 	DoneChanMap   = make(map[string]chan bool) | ||||
| 	mapMutex      = &sync.RWMutex{} | ||||
| 	// 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` | ||||
| 	// 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\";\nplease return your guess and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guess\": \"most_relevant_word_to_the_clue\",\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that you can choose from:\n%v` | ||||
| 	MimeSimplePrompt    = `we are playing alias;\nyou are to give one word clue and a number of words you mean your team to open; your team words: %v;\nhere are the words of opposite team you want to avoid: %v;\nand here is a black word that is critical not to pick: %s;\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-as-string\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nplease return json only.\nunopen Blue cards left: %d;\nunopen Red cards left: %d;` | ||||
| 	GuesserSimplePrompt   = `we are playing game of alias;\n you were given a clue: \"%s\";\nplease return your guess and words that could be meant by the clue, but you do not wish to open yet, in json like:\n{\n\"guess\": \"most_relevant_word_to_the_clue\",\n\"could_be\": [\"this\", \"that\", ...]\n}\nhere is the words that you can choose from:\n%v` | ||||
| 	MimeSimplePrompt      = `we are playing alias;\nyou are to give one word clue and a number of words you mean your team to open; your team words: %v;\nhere are the words of opposite team you want to avoid: %v;\nand here is a black word that is critical not to pick: %s;\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-as-string\",\n\"words_I_mean_my_team_to_open\": [\"this\", \"that\", ...]\n}\nplease return json only.` | ||||
| 	GuesserSimplePromptRU = `мы играем в alias;\n тебе дана подсказка (clue): \"%s\";\nпожалуйста, верни свою догадку (guess), а также слова, что тоже подходят к подсказке, но ты меньше в них уверен, в формате json; пример:\n{\n\"guess\": \"отгадка\",\n\"could_be\": [\"слово1\", \"слово2\", ...]\n}\nвот список слов из которых нужно выбрать:\n%v` | ||||
| 	MimeSimplePromptRU    = `мы играем в alias;\nтебе нужно дать подсказку одним словом и число слов, что ты подразумевал этой подсказкой; слова твоей комманды: %v;\nслова противоположной комманды, что ты хочешь избежать: %v;\nи вот ЧЕРНОЕ СЛОВО, открыв которое твоя комманда проиграет игру: %s;\nпожалуйста, верни подсказку (одним словом) и количество слов, что ты подразумеваешь в формате json; пример:\n{\n\"clue\": \"подсказка\",\n\"number\": \"число-от-0-до-9-as-string\",\n\"words_I_mean_my_team_to_open\": [\"слово1\", \"слово2\", ...]\n}\nпожалуйста верни только json.` | ||||
| ) | ||||
|  | ||||
| func convertToSliceOfStrings(value any) ([]string, error) { | ||||
| @@ -553,6 +553,9 @@ func (b *Bot) BuildSimpleGuesserPrompt(room *models.Room) string { | ||||
| 		} | ||||
| 		words[i] = card.Word | ||||
| 	} | ||||
| 	if strings.EqualFold(room.Settings.Language, "ru") { | ||||
| 		return fmt.Sprintf(MimeSimplePromptRU, clueAction.Word, words) | ||||
| 	} | ||||
| 	return fmt.Sprintf(GuesserSimplePrompt, clueAction.Word, words) | ||||
| } | ||||
|  | ||||
| @@ -581,34 +584,20 @@ func (b *Bot) BuildSimpleMimePrompt(room *models.Room) string { | ||||
| 			theirwords = append(theirwords, card.Word) | ||||
| 		} | ||||
| 	} | ||||
| 	return fmt.Sprintf(MimeSimplePrompt, ourwords, theirwords, blackWord, room.BlueCounter, room.RedCounter) | ||||
| 	if strings.EqualFold(room.Settings.Language, "ru") { | ||||
| 		return fmt.Sprintf(MimeSimplePromptRU, ourwords, theirwords, blackWord) | ||||
| 	} | ||||
| 	return fmt.Sprintf(MimeSimplePrompt, ourwords, theirwords, blackWord) | ||||
| } | ||||
|  | ||||
| func (b *Bot) BuildPrompt(room *models.Room) string { | ||||
| 	if b.Role == "" { | ||||
| 		return "" | ||||
| 	} | ||||
| 	// toText := make(map[string]any) | ||||
| 	// toText["backlog"] = room.ActionHistory | ||||
| 	// // mime sees all colors; | ||||
| 	// // guesser sees only revealed ones | ||||
| 	// if b.Role == models.UserRoleMime { | ||||
| 	// 	toText["cards"] = room.Cards | ||||
| 	// } | ||||
| 	// data, err := json.Marshal(toText) | ||||
| 	// if err != nil { | ||||
| 	// 	b.log.Error("failed to marshal", "error", err) | ||||
| 	// 	return "" | ||||
| 	// } | ||||
| 	// Escape the JSON string for inclusion in another JSON field | ||||
| 	// escapedData := strings.ReplaceAll(string(data), `"`, `\\"`) | ||||
| 	if b.Role == models.UserRoleMime { | ||||
| 		// return fmt.Sprintf(MimeSimplePrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) | ||||
| 		// return fmt.Sprintf(MimePrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) | ||||
| 		return b.BuildSimpleMimePrompt(room) | ||||
| 	} | ||||
| 	if b.Role == models.UserRoleGuesser { | ||||
| 		// return fmt.Sprintf(GuesserPrompt, b.Team, b.Team, room.BlueCounter, room.RedCounter, escapedData) | ||||
| 		return b.BuildSimpleGuesserPrompt(room) | ||||
| 	} | ||||
| 	return "" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder