Include local backend target in checkpoint identity
This commit is contained in:
@@ -312,6 +312,83 @@ func TestPromptKitClientCheckpointFingerprintTracksProfileSource(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptKitClientCheckpointFingerprintTracksLocalBackendTarget(t *testing.T) {
|
||||
const (
|
||||
firstEndpoint = "http://localhost:8000/v1"
|
||||
secondEndpoint = "https://inference.example.test/v1"
|
||||
)
|
||||
fingerprintsFor := func(endpoint string, concurrencyLimit int) []CheckpointFingerprint {
|
||||
t.Helper()
|
||||
client, err := NewPromptKitClient(PromptKitClientConfig{
|
||||
Assets: newTestPromptKitAssets(t),
|
||||
LocalBackend: &PromptKitLocalBackendConfig{
|
||||
Endpoint: endpoint,
|
||||
ConcurrencyLimit: concurrencyLimit,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
values, err := client.LLMCheckpointFingerprints()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
||||
baseline := fingerprintsFor(firstEndpoint, 0)
|
||||
if len(baseline) != 2 ||
|
||||
baseline[0].Name != promptKitProfileFingerprintName ||
|
||||
baseline[1].Name != promptKitLocalBackendFingerprintName {
|
||||
t.Fatalf("checkpoint fingerprints = %#v, want profile source then local backend target", baseline)
|
||||
}
|
||||
endpointChanged := fingerprintsFor(secondEndpoint, 0)
|
||||
if baseline[0] != endpointChanged[0] || baseline[1] == endpointChanged[1] {
|
||||
t.Fatalf("endpoint fingerprints = %#v and %#v, want only local target to change", baseline, endpointChanged)
|
||||
}
|
||||
concurrencyChanged := fingerprintsFor(firstEndpoint, 4)
|
||||
if !reflect.DeepEqual(baseline, concurrencyChanged) {
|
||||
t.Fatalf("concurrency fingerprints = %#v, want %#v", concurrencyChanged, baseline)
|
||||
}
|
||||
for _, values := range [][]CheckpointFingerprint{baseline, endpointChanged} {
|
||||
for _, fingerprint := range values {
|
||||
if strings.Contains(fingerprint.Value, firstEndpoint) ||
|
||||
strings.Contains(fingerprint.Value, secondEndpoint) {
|
||||
t.Fatalf("checkpoint fingerprint exposes endpoint: %#v", fingerprint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
localBackend := &PromptKitLocalBackendConfig{
|
||||
Endpoint: " " + firstEndpoint + " ",
|
||||
ConcurrencyLimit: 0,
|
||||
}
|
||||
client, err := NewPromptKitClient(PromptKitClientConfig{
|
||||
Assets: newTestPromptKitAssets(t),
|
||||
LocalBackend: localBackend,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
localBackend.Endpoint = secondEndpoint
|
||||
copy, err := client.LLMCheckpointFingerprints()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(copy, baseline) {
|
||||
t.Fatalf("fingerprints after input mutation = %#v, want retained target %#v", copy, baseline)
|
||||
}
|
||||
copy[0].Value = "mutated-profile"
|
||||
copy[1].Value = "mutated-target"
|
||||
fresh, err := client.LLMCheckpointFingerprints()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(fresh, baseline) {
|
||||
t.Fatalf("fingerprints after returned-slice mutation = %#v, want %#v", fresh, baseline)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptKitClientUsesPromptDefaultProfileWhenRequestProfileEmpty(t *testing.T) {
|
||||
fake := &fakePromptKitLLM{content: `{"ok":true}`}
|
||||
client := newTestPromptKitClient(t, fake)
|
||||
|
||||
Reference in New Issue
Block a user