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
7 changes: 6 additions & 1 deletion genkit-tools/common/src/eval/localFileDatasetStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ export class LocalFileDatasetStore implements DatasetStore {
const patchMap = new Map(patch.map((d) => [d.testCaseId, d]));

patchMap.forEach((value, key) => {
datasetMap.set(key, value);
// Delete sample if testCaseId is provided
if (value.testCaseId && !value.input && !value.reference) {
datasetMap.delete(key);
} else {
datasetMap.set(key, value);
}
});

const newDataset = Array.from(datasetMap.values()) as Dataset;
Expand Down
15 changes: 10 additions & 5 deletions js/testapps/evals/src/genkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@

import { devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore';
import { genkitEval, GenkitMetric } from '@genkit-ai/evaluator';
import { gemini15Flash, gemini15Pro, googleAI } from '@genkit-ai/googleai';
import { textEmbedding004, vertexAI } from '@genkit-ai/vertexai';
import {
gemini15Flash,
gemini15Pro,
googleAI,
textEmbeddingGecko001,
} from '@genkit-ai/googleai';
import { vertexAI } from '@genkit-ai/vertexai';
import {
vertexAIEvaluation,
VertexAIEvaluationMetricType,
Expand Down Expand Up @@ -54,8 +59,8 @@ export const ai = genkit({
genkitEval({
judge: gemini15Pro,
judgeConfig: PERMISSIVE_SAFETY_SETTINGS,
metrics: [GenkitMetric.FAITHFULNESS, GenkitMetric.MALICIOUSNESS],
embedder: textEmbedding004,
metrics: [GenkitMetric.MALICIOUSNESS],
embedder: textEmbeddingGecko001,
}),
vertexAI({
location: 'us-central1',
Expand All @@ -79,7 +84,7 @@ export const ai = genkit({
devLocalVectorstore([
{
indexName: 'pdfQA',
embedder: textEmbedding004,
embedder: textEmbeddingGecko001,
},
]),
langchain({
Expand Down
16 changes: 16 additions & 0 deletions js/testapps/evals/src/pdf-rag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ export const pdfQA = ai.defineFlow(
}
);

// Define a simple structured flow, we will evaluate this flow
export const simpleStructured = ai.defineFlow(
{
name: 'simpleStructured',
inputSchema: z.object({ query: z.string() }),
outputSchema: z.object({ response: z.string() }),
},
async (i) => {
const llmResponse = await ai.generate({
model: gemini15Flash,
prompt: i.query,
});
return { response: llmResponse.text };
}
);

const chunkingConfig = {
minLength: 1000, // number of minimum characters into chunk
maxLength: 2000, // number of maximum characters into chunk
Expand Down