basic_test.go 1.69 KB
Newer Older
1
2
3
4
5
6
//go:build integration

package integration

import (
	"context"
Daniel Hiltgen's avatar
Daniel Hiltgen committed
7
8
9
	"log/slog"
	"os"
	"runtime"
10
11
12
	"testing"
	"time"

13
	"github.com/ollama/ollama/api"
Daniel Hiltgen's avatar
Daniel Hiltgen committed
14
	"github.com/stretchr/testify/require"
15
16
17
)

func TestOrcaMiniBlueSky(t *testing.T) {
18
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
19
20
21
22
23
24
25
26
27
28
29
	defer cancel()
	// Set up the test data
	req := api.GenerateRequest{
		Model:  "orca-mini",
		Prompt: "why is the sky blue?",
		Stream: &stream,
		Options: map[string]interface{}{
			"temperature": 0,
			"seed":        123,
		},
	}
Daniel Hiltgen's avatar
Daniel Hiltgen committed
30
	GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
31
}
Daniel Hiltgen's avatar
Daniel Hiltgen committed
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70

func TestUnicodeModelDir(t *testing.T) {
	// This is only useful for Windows with utf-16 characters, so skip this test for other platforms
	if runtime.GOOS != "windows" {
		t.Skip("Unicode test only applicable to windows")
	}
	// Only works for local testing
	if os.Getenv("OLLAMA_TEST_EXISTING") != "" {
		t.Skip("TestUnicodeModelDir only works for local testing, skipping")
	}

	modelDir, err := os.MkdirTemp("", "ollama_埃")
	require.NoError(t, err)
	defer os.RemoveAll(modelDir)
	slog.Info("unicode", "OLLAMA_MODELS", modelDir)

	oldModelsDir := os.Getenv("OLLAMA_MODELS")
	if oldModelsDir == "" {
		defer os.Unsetenv("OLLAMA_MODELS")
	} else {
		defer os.Setenv("OLLAMA_MODELS", oldModelsDir)
	}
	err = os.Setenv("OLLAMA_MODELS", modelDir)
	require.NoError(t, err)

	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
	defer cancel()

	req := api.GenerateRequest{
		Model:  "orca-mini",
		Prompt: "why is the sky blue?",
		Stream: &stream,
		Options: map[string]interface{}{
			"temperature": 0,
			"seed":        123,
		},
	}
	GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
}