basic_test.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 TestUnicodeOutput(t *testing.T) {
  29. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
  30. defer cancel()
  31. // Set up the test data
  32. req := api.GenerateRequest{
  33. Model: "gemma2:2b",
  34. Prompt: "Output some smily face emoji",
  35. Stream: &stream,
  36. Options: map[string]interface{}{
  37. "temperature": 0,
  38. "seed": 123,
  39. },
  40. }
  41. GenerateTestHelper(ctx, t, req, []string{"😀", "😊", "😁", "😂", "😄", "😃"})
  42. }
  43. func TestUnicodeModelDir(t *testing.T) {
  44. // This is only useful for Windows with utf-16 characters, so skip this test for other platforms
  45. if runtime.GOOS != "windows" {
  46. t.Skip("Unicode test only applicable to windows")
  47. }
  48. // Only works for local testing
  49. if os.Getenv("OLLAMA_TEST_EXISTING") != "" {
  50. t.Skip("TestUnicodeModelDir only works for local testing, skipping")
  51. }
  52. modelDir, err := os.MkdirTemp("", "ollama_埃")
  53. require.NoError(t, err)
  54. defer os.RemoveAll(modelDir)
  55. slog.Info("unicode", "OLLAMA_MODELS", modelDir)
  56. t.Setenv("OLLAMA_MODELS", modelDir)
  57. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
  58. defer cancel()
  59. req := api.GenerateRequest{
  60. Model: "orca-mini",
  61. Prompt: "why is the sky blue?",
  62. Stream: &stream,
  63. Options: map[string]interface{}{
  64. "temperature": 0,
  65. "seed": 123,
  66. },
  67. }
  68. GenerateTestHelper(ctx, t, req, []string{"rayleigh", "scattering"})
  69. }