summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-02-02 10:05:43 +0300
committerGrail Finder <wohilas@gmail.com>2025-02-02 10:05:43 +0300
commit4e9b31baf885c6889d685b255ceb9bee6db7c06b (patch)
tree113168b858b914fc76c230a545711819ea2d02b5 /main_test.go
parent84c94ecea34753f246bdfd51f6ff989281e873e3 (diff)
Feat: remove thinking and tool msgs from ctx
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
new file mode 100644
index 0000000..0046ca2
--- /dev/null
+++ b/main_test.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "elefant/models"
+ "fmt"
+ "strings"
+ "testing"
+)
+
+func TestRemoveThinking(t *testing.T) {
+ cases := []struct {
+ cb *models.ChatBody
+ toolMsgs uint8
+ }{
+ {cb: &models.ChatBody{
+ Stream: true,
+ Messages: []models.RoleMsg{
+ {Role: "tool", Content: "should be ommited"},
+ {Role: "system", Content: "should stay"},
+ {Role: "user", Content: "hello, how are you?"},
+ {Role: "assistant", Content: "Oh, hi. <think>I should thank user and continue the conversation</think> I am geat, thank you! How are you?"},
+ },
+ },
+ toolMsgs: uint8(1),
+ },
+ }
+ for i, tc := range cases {
+ t.Run(fmt.Sprintf("run_%d", i), func(t *testing.T) {
+ mNum := len(tc.cb.Messages)
+ removeThinking(tc.cb)
+ if len(tc.cb.Messages) != mNum-int(tc.toolMsgs) {
+ t.Error("failed to delete tools msg", tc.cb.Messages, cfg.ToolRole)
+ }
+ for _, msg := range tc.cb.Messages {
+ if strings.Contains(msg.Content, "<think>") {
+ t.Errorf("msg contains think tag; msg: %s\n", msg.Content)
+ }
+ }
+ })
+ }
+}