basic_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. oldModelsDir := os.Getenv("OLLAMA_MODELS")
  42. if oldModelsDir == "" {
  43. defer os.Unsetenv("OLLAMA_MODELS")
  44. } else {
  45. defer os.Setenv("OLLAMA_MODELS", oldModelsDir)
  46. }
  47. err = os.Setenv("OLLAMA_MODELS", modelDir)
  48. require.NoError(t, err)
  49. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
  50. defer cancel()
  51. req := api.GenerateRequest{
  52. Model: "orca-mini",
  53. Prompt: "why is the sky blue?",
  54. Stream: &stream,
  55. Options: map[string]interface{}{
  56. "temperature": 0,
  57. "seed": 123,
  58. },
  59. }
  60. GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
  61. }