Skip to content

Commit 3182ef7

Browse files
committed
feat: add fixture-match debug logging to all LLM handlers
Add logger.debug at fixture match point in all 12 remaining handlers (search.ts, rerank.ts, moderation.ts already had it). Logs fixture matched/no-match for debugging fixture resolution issues.
1 parent 1796ae1 commit 3182ef7

12 files changed

Lines changed: 70 additions & 0 deletions

src/bedrock-converse.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ export async function handleConverse(
365365
defaults.requestTransform,
366366
);
367367

368+
if (fixture) {
369+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
370+
} else {
371+
logger.debug(`No fixture matched for request`);
372+
}
373+
368374
if (fixture) {
369375
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
370376
}
@@ -616,6 +622,12 @@ export async function handleConverseStream(
616622
defaults.requestTransform,
617623
);
618624

625+
if (fixture) {
626+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
627+
} else {
628+
logger.debug(`No fixture matched for request`);
629+
}
630+
619631
if (fixture) {
620632
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
621633
}

src/bedrock.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ export async function handleBedrock(
358358
defaults.requestTransform,
359359
);
360360

361+
if (fixture) {
362+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
363+
} else {
364+
logger.debug(`No fixture matched for request`);
365+
}
366+
361367
if (fixture) {
362368
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
363369
}
@@ -926,6 +932,12 @@ export async function handleBedrockStream(
926932
defaults.requestTransform,
927933
);
928934

935+
if (fixture) {
936+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
937+
} else {
938+
logger.debug(`No fixture matched for request`);
939+
}
940+
929941
if (fixture) {
930942
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
931943
}

src/cohere.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ export async function handleCohere(
786786

787787
if (fixture) {
788788
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
789+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
790+
} else {
791+
logger.debug(`No fixture matched for request`);
789792
}
790793

791794
if (

src/embeddings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export async function handleEmbeddings(
126126

127127
if (fixture) {
128128
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
129+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
130+
} else {
131+
logger.debug(`No fixture matched for request`);
129132
}
130133

131134
if (

src/gemini.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,12 @@ export async function handleGemini(
549549
);
550550
const path = req.url ?? `/v1beta/models/${model}:generateContent`;
551551

552+
if (fixture) {
553+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
554+
} else {
555+
logger.debug(`No fixture matched for request`);
556+
}
557+
552558
if (fixture) {
553559
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
554560
}

src/images.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export async function handleImages(
106106

107107
if (fixture) {
108108
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
109+
defaults.logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
110+
} else {
111+
defaults.logger.debug(`No fixture matched for request`);
109112
}
110113

111114
if (

src/messages.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,14 @@ export async function handleMessages(
737737

738738
if (fixture) {
739739
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
740+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
741+
} else {
742+
const lastUserMsg = completionReq.messages.filter((m) => m.role === "user").pop();
743+
const snippet =
744+
typeof lastUserMsg?.content === "string" ? lastUserMsg.content.slice(0, 80) : "";
745+
logger.debug(
746+
`No fixture matched for request (model=${completionReq.model ?? "?"}, msg="${snippet}")`,
747+
);
740748
}
741749

742750
if (

src/ollama.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ export async function handleOllama(
498498

499499
if (fixture) {
500500
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
501+
logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
502+
} else {
503+
logger.debug(`No fixture matched for request`);
501504
}
502505

503506
if (
@@ -800,6 +803,9 @@ export async function handleOllamaGenerate(
800803

801804
if (fixture) {
802805
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
806+
defaults.logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
807+
} else {
808+
defaults.logger.debug(`No fixture matched for request`);
803809
}
804810

805811
if (

src/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,14 @@ async function handleCompletions(
462462

463463
if (fixture) {
464464
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
465+
defaults.logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
466+
} else {
467+
const lastUserMsg = body.messages.filter((m) => m.role === "user").pop();
468+
const snippet =
469+
typeof lastUserMsg?.content === "string" ? lastUserMsg.content.slice(0, 80) : "";
470+
defaults.logger.debug(
471+
`No fixture matched for request (model=${body.model ?? "?"}, msg="${snippet}")`,
472+
);
465473
}
466474

467475
const method = req.method ?? "POST";

src/speech.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ export async function handleSpeech(
9393

9494
if (fixture) {
9595
journal.incrementFixtureMatchCount(fixture, fixtures, testId);
96+
defaults.logger.debug(`Fixture matched: ${JSON.stringify(fixture.match).slice(0, 120)}`);
97+
} else {
98+
defaults.logger.debug(`No fixture matched for request`);
9699
}
97100

98101
if (

0 commit comments

Comments
 (0)