basic_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //go:build integration
  2. package integration
  3. import (
  4. "context"
  5. "log/slog"
  6. "os"
  7. "runtime"
  8. "testing"
  9. "time"
  10. "github.com/ollama/ollama/api"
  11. "github.com/stretchr/testify/require"
  12. )
  13. func TestOrcaMiniBlueSky(t *testing.T) {
  14. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
  15. defer cancel()
  16. // Set up the test data
  17. req := api.GenerateRequest{
  18. Model: "orca-mini",
  19. Prompt: "why is the sky blue?",
  20. Stream: &stream,
  21. Options: map[string]interface{}{
  22. "temperature": 0,
  23. "seed": 123,
  24. },
  25. }
  26. GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
  27. }
  28. func TestUnicodeModelDir(t *testing.T) {
  29. // This is only useful for Windows with utf-16 characters, so skip this test for other platforms
  30. if runtime.GOOS != "windows" {
  31. t.Skip("Unicode test only applicable to windows")
  32. }
  33. // Only works for local testing
  34. if os.Getenv("OLLAMA_TEST_EXISTING") != "" {
  35. t.Skip("TestUnicodeModelDir only works for local testing, skipping")
  36. }
  37. modelDir, err := os.MkdirTemp("", "ollama_埃")
  38. require.NoError(t, err)
  39. defer os.RemoveAll(modelDir)
  40. slog.Info("unicode", "OLLAMA_MODELS", modelDir)
  41. t.Setenv("OLLAMA_MODELS", modelDir)
  42. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
  43. defer cancel()
  44. req := api.GenerateRequest{
  45. Model: "orca-mini",
  46. Prompt: "why is the sky blue?",
  47. Stream: &stream,
  48. Options: map[string]interface{}{
  49. "temperature": 0,
  50. "seed": 123,
  51. },
  52. }
  53. GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
  54. }