Files
photoprism/internal/ai/vision/engine_ollama_test.go
2025-11-14 11:10:40 +01:00

40 lines
1.1 KiB
Go

package vision
import (
"context"
"encoding/json"
"testing"
"github.com/photoprism/photoprism/internal/ai/vision/ollama"
)
func TestOllamaDefaultConfidenceApplied(t *testing.T) {
req := &ApiRequest{Format: FormatJSON}
payload := ollama.Response{
Result: ollama.ResultPayload{
Labels: []ollama.LabelPayload{{Name: "forest path", Confidence: 0, Topicality: 0}},
},
}
raw, err := json.Marshal(payload)
if err != nil {
t.Fatalf("marshal: %v", err)
}
parser := ollamaParser{}
resp, err := parser.Parse(context.Background(), req, raw, 200)
if err != nil {
t.Fatalf("parse failed: %v", err)
}
if len(resp.Result.Labels) != 1 {
t.Fatalf("expected one label, got %d", len(resp.Result.Labels))
}
if resp.Result.Labels[0].Confidence != ollama.LabelConfidenceDefault {
t.Fatalf("expected default confidence %.2f, got %.2f", ollama.LabelConfidenceDefault, resp.Result.Labels[0].Confidence)
}
if resp.Result.Labels[0].Topicality != ollama.LabelConfidenceDefault {
t.Fatalf("expected topicality to default to confidence, got %.2f", resp.Result.Labels[0].Topicality)
}
}