2024-04-04 14:42:17 +00:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ollama/ollama/api"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestContextExhaustion(t *testing.T) {
|
2024-06-05 19:07:20 +00:00
|
|
|
// Longer needed for small footprint GPUs
|
2024-07-09 22:28:25 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
2024-04-04 14:42:17 +00:00
|
|
|
defer cancel()
|
|
|
|
// Set up the test data
|
|
|
|
req := api.GenerateRequest{
|
|
|
|
Model: "llama2",
|
|
|
|
Prompt: "Write me a story with a ton of emojis?",
|
|
|
|
Stream: &stream,
|
|
|
|
Options: map[string]interface{}{
|
|
|
|
"temperature": 0,
|
|
|
|
"seed": 123,
|
|
|
|
"num_ctx": 128,
|
|
|
|
},
|
|
|
|
}
|
2024-07-09 22:28:25 +00:00
|
|
|
client, _, cleanup := InitServerConnection(ctx, t)
|
|
|
|
defer cleanup()
|
|
|
|
if err := PullIfMissing(ctx, client, req.Model); err != nil {
|
|
|
|
t.Fatalf("PullIfMissing failed: %v", err)
|
|
|
|
}
|
|
|
|
DoGenerate(ctx, t, client, req, []string{"once", "upon", "lived"}, 120*time.Second, 10*time.Second)
|
2024-04-04 14:42:17 +00:00
|
|
|
}
|