context_test.go 832 B

12345678910111213141516171819202122232425262728293031323334
  1. //go:build integration
  2. package integration
  3. import (
  4. "context"
  5. "testing"
  6. "time"
  7. "github.com/ollama/ollama/api"
  8. )
  9. func TestContextExhaustion(t *testing.T) {
  10. // Longer needed for small footprint GPUs
  11. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
  12. defer cancel()
  13. // Set up the test data
  14. req := api.GenerateRequest{
  15. Model: "llama2",
  16. Prompt: "Write me a story with a ton of emojis?",
  17. Stream: &stream,
  18. Options: map[string]interface{}{
  19. "temperature": 0,
  20. "seed": 123,
  21. "num_ctx": 128,
  22. },
  23. }
  24. client, _, cleanup := InitServerConnection(ctx, t)
  25. defer cleanup()
  26. if err := PullIfMissing(ctx, client, req.Model); err != nil {
  27. t.Fatalf("PullIfMissing failed: %v", err)
  28. }
  29. DoGenerate(ctx, t, client, req, []string{"once", "upon", "lived"}, 120*time.Second, 10*time.Second)
  30. }