diff --git a/web/app/components/evaluation/__tests__/index.spec.tsx b/web/app/components/evaluation/__tests__/index.spec.tsx
index a3b0d2fcac..95e295903d 100644
--- a/web/app/components/evaluation/__tests__/index.spec.tsx
+++ b/web/app/components/evaluation/__tests__/index.spec.tsx
@@ -622,6 +622,33 @@ describe('Evaluation', () => {
expect(screen.getByRole('button', { name: 'evaluation.pipeline.uploadAndRun' })).toBeEnabled()
})
+ it('should download the fixed pipeline template columns', () => {
+ const createElement = document.createElement.bind(document)
+ let downloadLink: HTMLAnchorElement | undefined
+ const createElementSpy = vi.spyOn(document, 'createElement').mockImplementation((tagName, options) => {
+ const element = createElement(tagName, options)
+
+ if (tagName === 'a') {
+ downloadLink = element as HTMLAnchorElement
+ vi.spyOn(downloadLink, 'click').mockImplementation(() => {})
+ }
+
+ return element
+ })
+
+ renderWithQueryClient()
+
+ fireEvent.click(screen.getByRole('button', { name: 'select-model' }))
+ fireEvent.click(screen.getByRole('button', { name: /Context Precision/i }))
+ fireEvent.click(screen.getByRole('button', { name: 'evaluation.batch.downloadTemplate' }))
+
+ expect(downloadLink?.download).toBe('pipeline-evaluation-template.csv')
+ expect(decodeURIComponent(downloadLink?.href ?? '')).toContain('query,expect_results\n')
+ expect(decodeURIComponent(downloadLink?.href ?? '')).not.toContain('expected_output')
+
+ createElementSpy.mockRestore()
+ })
+
it('should upload and start a pipeline evaluation run', async () => {
const startRun = vi.fn()
mockUseStartEvaluationRunMutation.mockReturnValue({
@@ -640,14 +667,14 @@ describe('Evaluation', () => {
fireEvent.click(screen.getByRole('button', { name: 'evaluation.pipeline.uploadAndRun' }))
expect(screen.getAllByText('query').length).toBeGreaterThan(0)
- expect(screen.getAllByText('Expect Results').length).toBeGreaterThan(0)
+ expect(screen.getAllByText('expect_results').length).toBeGreaterThan(0)
const fileInput = document.querySelector('input[type="file"][accept=".csv"]')
expect(fileInput).toBeInTheDocument()
fireEvent.change(fileInput!, {
target: {
- files: [new File(['query,Expect Results'], 'pipeline-evaluation.csv', { type: 'text/csv' })],
+ files: [new File(['query,expect_results'], 'pipeline-evaluation.csv', { type: 'text/csv' })],
},
})
diff --git a/web/app/components/evaluation/components/batch-test-panel/input-fields/use-input-fields-actions.ts b/web/app/components/evaluation/components/batch-test-panel/input-fields/use-input-fields-actions.ts
index f390b9a9ad..c4b4b0182b 100644
--- a/web/app/components/evaluation/components/batch-test-panel/input-fields/use-input-fields-actions.ts
+++ b/web/app/components/evaluation/components/batch-test-panel/input-fields/use-input-fields-actions.ts
@@ -21,6 +21,7 @@ type UseInputFieldsActionsParams = EvaluationResourceProps & {
isInputFieldsLoading: boolean
isPanelReady: boolean
isRunnable: boolean
+ templateContent?: string
templateFileName: string
}
@@ -31,6 +32,7 @@ export const useInputFieldsActions = ({
isInputFieldsLoading,
isPanelReady,
isRunnable,
+ templateContent,
templateFileName,
}: UseInputFieldsActionsParams) => {
const { t } = useTranslation('evaluation')
@@ -79,7 +81,7 @@ export const useInputFieldsActions = ({
return
}
- const content = buildTemplateCsvContent(inputFields)
+ const content = templateContent ?? buildTemplateCsvContent(inputFields)
const link = document.createElement('a')
link.href = `data:text/csv;charset=utf-8,${encodeURIComponent(content)}`
link.download = templateFileName
diff --git a/web/app/components/evaluation/components/pipeline/pipeline-batch-actions.tsx b/web/app/components/evaluation/components/pipeline/pipeline-batch-actions.tsx
index 0051491d80..474227c660 100644
--- a/web/app/components/evaluation/components/pipeline/pipeline-batch-actions.tsx
+++ b/web/app/components/evaluation/components/pipeline/pipeline-batch-actions.tsx
@@ -13,6 +13,7 @@ const PIPELINE_INPUT_FIELDS: InputField[] = [
{ name: 'query', type: 'string' },
{ name: 'expect_results', type: 'string' },
]
+const PIPELINE_TEMPLATE_CONTENT = 'query,expect_results\n'
const PipelineBatchActions = ({
resourceType,
@@ -29,6 +30,7 @@ const PipelineBatchActions = ({
isInputFieldsLoading: false,
isPanelReady: isConfigReady,
isRunnable,
+ templateContent: PIPELINE_TEMPLATE_CONTENT,
templateFileName: EVALUATION_TEMPLATE_FILE_NAMES[resourceType],
})