aboutsummaryrefslogtreecommitdiff
path: root/internal/textgeneration/textgen_test.go
blob: 75ae36cca22559b3c0902c349e9a0ef9ef8028b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package textgen

import (
	"context"
	"fmt"
	"os"
	"strconv"
	"testing"
)

func TestApplyCharacter(t *testing.T) {
	cr := new(ChatRequest)
	if err := cr.ApplyCharacter("yasomi"); err != nil {
		t.Fatalf("%v", err)
	}

	if cr.BotName != "Midori Yasomi" {
		t.Fatalf("expected bot name to be %q, got: %q", "Midori Yasomi", cr.BotName)
	}

	t.Log(cr.Context)
}

func TestApplyPreset(t *testing.T) {
	cr := new(ChatRequest)
	if err := cr.ApplyPreset("Kobold-Godlike"); err != nil {
		t.Fatalf("%v", err)
	}
}

func TestTextGen(t *testing.T) {
	if ok, _ := strconv.ParseBool(os.Getenv("TEXTGEN_REALWORLD")); !ok {
		t.Skip("TEXTGEN_REALWORLD is not set, not testing.")
	}

	cr := new(ChatRequest)
	if err := cr.ApplyPreset("Default"); err != nil {
		t.Fatalf("%v", err)
	}

	if err := cr.ApplyCharacter("yasomi"); err != nil {
		t.Fatalf("%v", err)
	}

	cr.Input = "So, what's the deal with airline food?"
	cr.MaxNewTokens = 200
	cr.DoSample = true
	cr.EarlyStopping = true

	resp, err := Generate(context.Background(), cr)
	if err != nil {
		t.Fatal(err)
	}

	fmt.Println(resp.Data[0])
}