"vscode:/vscode.git/clone" did not exist on "a851dd99207e10306837e53514e32c2ba473921d"
llm_test.go 1.87 KB
Newer Older
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
//go:build integration

package integration

import (
	"context"
	"net/http"
	"sync"
	"testing"
	"time"

	"github.com/jmorganca/ollama/api"
)

// TODO - this would ideally be in the llm package, but that would require some refactoring of interfaces in the server
//        package to avoid circular dependencies

// WARNING - these tests will fail on mac if you don't manually copy ggml-metal.metal to this dir (./server)
//
// TODO - Fix this ^^

var (
	stream = false
	req    = [2]api.GenerateRequest{
		{
			Model:  "orca-mini",
			Prompt: "why is the ocean blue?",
			Stream: &stream,
			Options: map[string]interface{}{
				"seed":        42,
				"temperature": 0.0,
			},
		}, {
			Model:  "orca-mini",
			Prompt: "what is the origin of the us thanksgiving holiday?",
			Stream: &stream,
			Options: map[string]interface{}{
				"seed":        42,
				"temperature": 0.0,
			},
		},
	}
43
44
45
	resp = [2][]string{
		[]string{"sunlight"},
		[]string{"england", "english", "massachusetts", "pilgrims"},
46
47
48
49
	}
)

func TestIntegrationSimpleOrcaMini(t *testing.T) {
50
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
51
	defer cancel()
52
	GenerateTestHelper(ctx, t, &http.Client{}, req[0], resp[0])
53
54
55
56
57
58
59
60
61
}

// TODO
// The server always loads a new runner and closes the old one, which forces serial execution
// At present this test case fails with concurrency problems.  Eventually we should try to
// get true concurrency working with n_parallel support in the backend
func TestIntegrationConcurrentPredictOrcaMini(t *testing.T) {
	var wg sync.WaitGroup
	wg.Add(len(req))
62
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
63
64
65
66
	defer cancel()
	for i := 0; i < len(req); i++ {
		go func(i int) {
			defer wg.Done()
67
			GenerateTestHelper(ctx, t, &http.Client{}, req[i], resp[i])
68
69
70
71
72
73
		}(i)
	}
	wg.Wait()
}

// TODO - create a parallel test with 2 different models once we support concurrency