From 10cca9037fac14fff966dd1fd6e9de86893d3981 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Thu, 1 May 2025 07:08:03 +0300 Subject: [PATCH] Fix: tool description --- bot.go | 41 ++++++++++++++++++++++++----------------- extra/twentyq.go | 11 +++++++++++ tools.go | 6 +++--- 3 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 extra/twentyq.go diff --git a/bot.go b/bot.go index 8aff41d..f6770e7 100644 --- a/bot.go +++ b/bot.go @@ -272,6 +272,28 @@ func roleToIcon(role string) string { return "<" + role + ">: " } +func checkGame(role string, tv *tview.TextView) { + // Handle Cluedo game flow + // should go before form msg, since formmsg takes chatBody and makes ioreader out of it + // role is almost always user, unless it's regen or resume + // cannot get in this block, since cluedoState is nil; + // check if cfg.EnableCluedo is true and init the cluedo state; ai! + if cfg.EnableCluedo && cluedoState != nil { + notifyUser("got in cluedo", "yay") + currentPlayer := playerOrder[0] + playerOrder = append(playerOrder[1:], currentPlayer) // Rotate turns + if role == cfg.UserRole { + fmt.Fprintf(tv, "Your (%s) cards: %s\n", currentPlayer, cluedoState.GetPlayerCards(currentPlayer)) + } else { + chatBody.Messages = append(chatBody.Messages, models.RoleMsg{ + Role: cfg.ToolRole, + Content: cluedoState.GetPlayerCards(currentPlayer), + }) + } + } + return +} + func chatRound(userMsg, role string, tv *tview.TextView, regen, resume bool) { botRespMode = true defer func() { botRespMode = false }() @@ -285,23 +307,8 @@ func chatRound(userMsg, role string, tv *tview.TextView, regen, resume bool) { return } } - // Handle Cluedo game flow - // should go before form msg, since formmsg takes chatBody and makes ioreader out of it - // role is almost always user, unless it's regen or resume - // cannot get in this block, since cluedoState is nil; - // check if cfg.EnableCluedo is true and init the cluedo state; ai! - if cfg.EnableCluedo && cluedoState != nil && !resume { - notifyUser("got in cluedo", "yay") - currentPlayer := playerOrder[0] - playerOrder = append(playerOrder[1:], currentPlayer) // Rotate turns - if role == cfg.UserRole { - fmt.Fprintf(tv, "Your (%s) cards: %s\n", currentPlayer, cluedoState.GetPlayerCards(currentPlayer)) - } else { - chatBody.Messages = append(chatBody.Messages, models.RoleMsg{ - Role: cfg.ToolRole, - Content: cluedoState.GetPlayerCards(currentPlayer), - }) - } + if !resume { + checkGame(role, tv) } choseChunkParser() reader, err := chunkParser.FormMsg(userMsg, role, resume) diff --git a/extra/twentyq.go b/extra/twentyq.go new file mode 100644 index 0000000..30c08cc --- /dev/null +++ b/extra/twentyq.go @@ -0,0 +1,11 @@ +package extra + +import "math/rand" + +var ( + chars = []string{"Shrek", "Garfield", "Jack the Ripper"} +) + +func GetRandomChar() string { + return chars[rand.Intn(len(chars))] +} diff --git a/tools.go b/tools.go index 50b3d24..626aa02 100644 --- a/tools.go +++ b/tools.go @@ -26,7 +26,7 @@ Your current tools: [ { "name":"recall", -"args": "topic", +"args": ["topic"], "when_to_use": "when asked about topic that user previously asked to memorise" }, { @@ -36,7 +36,7 @@ Your current tools: }, { "name":"recall_topics", -"args": null, +"args": [], "when_to_use": "to see what topics are saved in memory" } ] @@ -46,7 +46,7 @@ To make a function call return a json object within __tool_call__ tags; __tool_call__ { "name":"recall", -"args": "Adam's number" +"args": ["Adam's number"] } __tool_call__