Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public sealed record RetrievalCompleted(
IReadOnlyList<Guid> LeftOut,
double MinScore,
double ConfidentScore,
int? RetrievalMs);
int? RetrievalMs,
double? BestScore = null);

public sealed record AnswerDelta(string Text);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ await events.WriteAsync(
AnswerEvents.Item(
AnswerEvents.RetrievalCompletedType,
new AnswerEvents.RetrievalCompleted(
found.Outcome.ToApi(), sources, scope, attempt.UnavailableDocumentIds, found.Thresholds.MinScore, found.Thresholds.ConfidentScore, attempt.RetrievalMs)),
found.Outcome.ToApi(), sources, scope, attempt.UnavailableDocumentIds, found.Thresholds.MinScore, found.Thresholds.ConfidentScore, attempt.RetrievalMs, found.BestScore)),
aborted);

if (found.Outcome == EvidenceOutcome.NoEvidence)
Expand Down Expand Up @@ -410,6 +410,7 @@ private RequestTrace Trace(Attempt attempt, AnswerStatus status, RefusalReason?
MinScore = found?.Thresholds.MinScore,
ConfidentScore = found?.Thresholds.ConfidentScore,
DuplicateOverlap = found?.Thresholds.DuplicateOverlap,
BestScore = found?.BestScore,
EmbeddingModel = found?.EmbeddingModel,
RetrievedPassages = JsonSerializer.Serialize(passages, TraceJson),
ChatModel = attempt.ChatModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ internal sealed class RequestTrace

public double? DuplicateOverlap { get; set; }

/// <summary>The best score among the candidates before the evidence rules; shows how close a refused question came (null when nothing matched).</summary>
public double? BestScore { get; set; }

public string? EmbeddingModel { get; set; }

/// <summary>JSON array of <see cref="RetrievedPassageTrace"/>, stored as <c>jsonb</c>.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public sealed record ScopeStep(string? Language, IReadOnlyList<string> Tags, IRe

public sealed record ScopeDocument(Guid Id, string? Title, bool Available);

public sealed record RetrievalStep(string? Outcome, double? MinScore, double? ConfidentScore, int? Ms, IReadOnlyList<PassageStep> Passages);
/// <param name="BestScore">The best candidate before the evidence rules; explains a refusal (null when nothing matched, or on older traces).</param>
public sealed record RetrievalStep(
string? Outcome, double? MinScore, double? ConfidentScore, int? Ms, IReadOnlyList<PassageStep> Passages, double? BestScore = null);

public sealed record PassageStep(
int Rank,
Expand Down Expand Up @@ -87,7 +89,7 @@ orderby t.Attempt descending
trace.QuestionText,
new RewriteStep(trace.RewriteUsed, trace.RetrievalQuery, trace.RewriteFallbackReason?.ToApi(), trace.RewriteMs),
new ScopeStep(trace.FilterLanguage, trace.FilterTags, documents),
new RetrievalStep(trace.EvidenceOutcome is { } outcome ? JsonNamingPolicy.CamelCase.ConvertName(outcome) : null, trace.MinScore, trace.ConfidentScore, trace.RetrievalMs, passages),
new RetrievalStep(trace.EvidenceOutcome is { } outcome ? JsonNamingPolicy.CamelCase.ConvertName(outcome) : null, trace.MinScore, trace.ConfidentScore, trace.RetrievalMs, passages, trace.BestScore),
new AnswerStep(
trace.ChatModel is not null,
trace.FinalStatus.ToApi(),
Expand Down
Loading
Loading