Skip to content

Commit 2861384

Browse files
authored
feat: throw for unknown CLI commands, traceId in eval:* (#3693)
1 parent 2d44d1b commit 2861384

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

genkit-tools/cli/src/cli.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ export async function startCLI(): Promise<void> {
138138
logger.info(program.help());
139139
})
140140
);
141-
// Default action to catch unknown commands.
142-
program.action(() => {
143-
// print help
141+
// Handle unknown commands.
142+
program.on('command:*', (operands) => {
143+
logger.error(`error: unknown command '${operands[0]}'`);
144144
logger.info(program.help());
145+
process.exit(1);
145146
});
146147

147148
await program.parseAsync();

genkit-tools/common/src/eval/evaluate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ export async function runEvaluation(params: {
193193
},
194194
});
195195
scores[name] = response.result;
196+
logger.info(
197+
`Finished evaluator '${action.name}'. Trace ID: ${response.telemetry?.traceId}`
198+
);
196199
}
197200

198201
const scoredResults = enrichResultsWithScoring(scores, evalDataset);

js/testapps/evals/src/genkit.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616

1717
import { devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore';
1818
import { GenkitMetric, genkitEval } from '@genkit-ai/evaluator';
19-
import {
20-
gemini15Flash,
21-
gemini15Pro,
22-
googleAI,
23-
textEmbeddingGecko001,
24-
} from '@genkit-ai/googleai';
19+
import { googleAI } from '@genkit-ai/googleai';
2520
import { genkit } from 'genkit';
2621
import { langchain } from 'genkitx-langchain';
2722

@@ -55,27 +50,27 @@ export const ai = genkit({
5550
metrics: [
5651
{
5752
type: GenkitMetric.MALICIOUSNESS,
58-
judge: gemini15Pro,
53+
judge: googleAI.model('gemini-2.5-pro'),
5954
judgeConfig: PERMISSIVE_SAFETY_SETTINGS,
6055
},
6156
{
6257
type: GenkitMetric.ANSWER_ACCURACY,
63-
judge: gemini15Pro,
58+
judge: googleAI.model('gemini-2.5-pro'),
6459
judgeConfig: PERMISSIVE_SAFETY_SETTINGS,
6560
},
6661
],
6762
}),
6863
devLocalVectorstore([
6964
{
7065
indexName: 'pdfQA',
71-
embedder: textEmbeddingGecko001,
66+
embedder: googleAI.embedder('text-embedding-004'),
7267
},
7368
]),
7469
langchain({
7570
evaluators: {
7671
criteria: ['coherence'],
7772
labeledCriteria: ['correctness'],
78-
judge: gemini15Flash,
73+
judge: googleAI.model('gemini-2.5-pro'),
7974
},
8075
}),
8176
],

js/testapps/evals/src/pdf-rag.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
devLocalIndexerRef,
1919
devLocalRetrieverRef,
2020
} from '@genkit-ai/dev-local-vectorstore';
21-
import { gemini15Flash } from '@genkit-ai/googleai';
21+
import googleAI from '@genkit-ai/googleai';
2222
import { z } from 'genkit';
2323
import { EvalStatusEnum, type BaseEvalDataPoint } from 'genkit/evaluator';
2424
import { Document } from 'genkit/retriever';
@@ -70,7 +70,7 @@ export const pdfQA = ai.defineFlow(
7070
context: docs.map((d) => d.text).join('\n\n'),
7171
});
7272
const llmResponse = await ai.generate({
73-
model: gemini15Flash,
73+
model: googleAI.model('gemini-2.5-flash'),
7474
prompt: augmentedPrompt,
7575
});
7676
return llmResponse.text;
@@ -86,7 +86,7 @@ export const simpleStructured = ai.defineFlow(
8686
},
8787
async (i) => {
8888
const llmResponse = await ai.generate({
89-
model: gemini15Flash,
89+
model: googleAI.model('gemini-2.5-flash'),
9090
prompt: i.query,
9191
});
9292
return { response: llmResponse.text };
@@ -102,7 +102,7 @@ export const simpleEcho = ai.defineFlow(
102102
},
103103
async (i) => {
104104
const llmResponse = await ai.generate({
105-
model: gemini15Flash,
105+
model: googleAI.model('gemini-2.5-flash'),
106106
prompt: i,
107107
});
108108
return llmResponse.text;

0 commit comments

Comments
 (0)