Chore: solved some todos

This commit is contained in:
Grail Finder
2025-06-12 07:04:20 +03:00
parent 6934b724ae
commit 74b10b8395
10 changed files with 50 additions and 82 deletions

View File

@ -15,13 +15,6 @@ import (
"strings"
)
// TODO: config for url and token
// completion prompt
// MIME: llm needs to know all the cards, colors and previous actions
// GUESSER: llm needs to know all the cards and previous actions
// channels are not serializable
var (
// botname -> channel
SignalChanMap = make(map[string]chan bool)
@ -29,7 +22,6 @@ 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`
GuesserPrompt = `we are playing alias;\nyou are to guess words of the %s team (people who would guess by your clue want open the %s cards) by given clue and a number of meant guesses;\nplease return your guesses and words that you did not wish to open, but think that they could be also meant by the clue 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 game info in json:\n%s`
// notifier =
)
type DSResp struct {
@ -245,6 +237,13 @@ func NewBot(role, team, name, roomID string, cfg *config.Config) (*Bot, error) {
Role: models.StrToUserRole(role),
Team: models.StrToUserTeam(team),
}
// check if already has the same team-role bot
// only one is allowed
for n, p := range room.BotMap {
if p.Role == bp.Role && p.Team == bp.Team {
return nil, fmt.Errorf("already has such bot with name: %s", n)
}
}
room.BotMap[name] = bp
switch team {
case "red":
@ -385,11 +384,5 @@ func (b *Bot) CallLLM(prompt string) ([]byte, error) {
return nil, err
}
b.log.Debug("llm resp", "body", string(body))
// TODO: case where it has other text, not only json
// TODO: how to know which resp it is? mime or guessser?
// resp := &MimeResp{}
// if err := json.Unmarshal(body, &resp); err != nil {
// return nil, err
// }
return body, nil
}