> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # CI의 득점자 실행 CI 파이프라인에서 득점자를 실행하면 시간 경과에 따른 Agent 품질을 측정하기 위한 수량화 가능한 측정항목이 제공됩니다. 그만큼`runEvals`함수는 Agent 또는 Workflow를 통해 여러 테스트 사례를 처리하고 집계 점수를 반환합니다. ## 기본 설정 [Vitest](https://vitest.dev/), [Jest](https://jestjs.io/) 또는 [Mocha](https://mochajs.org/)처럼 ESM 모듈을 지원하는 모든 테스트 프레임워크를 사용할 수 있습니다. ## 테스트 케이스 만들기 여러 테스트 사례에 대해 Agent를 평가하려면 `runEvals`를 사용하세요. 이 함수는 데이터 항목 배열을 받으며, 각 항목에는 `input`과 채점자 검증에 사용할 선택적 `groundTruth`가 포함됩니다. ```typescript import { describe, it, expect } from 'vitest' import { createScorer, runEvals } from '@mastra/core/evals' import { weatherAgent } from './weather-agent' import { locationScorer } from '../scorers/location-scorer' describe('Weather Agent Tests', () => { it('should correctly extract locations from queries', async () => { const result = await runEvals({ data: [ { input: 'weather in Berlin', groundTruth: { expectedLocation: 'Berlin', expectedCountry: 'DE' }, }, { input: 'weather in Berlin, Maryland', groundTruth: { expectedLocation: 'Berlin', expectedCountry: 'US' }, }, { input: 'weather in Berlin, Russia', groundTruth: { expectedLocation: 'Berlin', expectedCountry: 'RU' }, }, ], target: weatherAgent, scorers: [locationScorer], }) // Assert aggregate score meets threshold expect(result.scores['location-accuracy']).toBe(1) expect(result.summary.totalItems).toBe(3) }) }) ``` ## 결과 이해 `runEvals` 함수는 다음 항목을 포함한 객체를 반환합니다. - `scores`: 모든 테스트 케이스에 걸쳐 각 채점자의 평균 점수 - `summary.totalItems`: 처리된 총 테스트 케이스 수 ```typescript { scores: { 'location-accuracy': 1.0, // Average score across all items 'another-scorer': 0.85 }, summary: { totalItems: 3 } } ``` ## 여러 테스트 시나리오 다양한 평가 시나리오에 대해 별도의 테스트 사례를 만듭니다. ```typescript describe('Weather Agent Tests', () => { const locationScorer = createScorer({/* ... */}) it('should handle location disambiguation', async () => { const result = await runEvals({ data: [ { input: 'weather in Berlin', groundTruth: {/* ... */}, }, { input: 'weather in Berlin, Maryland', groundTruth: {/* ... */}, }, ], target: weatherAgent, scorers: [locationScorer], }) expect(result.scores['location-accuracy']).toBe(1) }) it('should handle typos and misspellings', async () => { const result = await runEvals({ data: [ { input: 'weather in Berln', groundTruth: { expectedLocation: 'Berlin', expectedCountry: 'DE' }, }, { input: 'weather in Parris', groundTruth: { expectedLocation: 'Paris', expectedCountry: 'FR' }, }, ], target: weatherAgent, scorers: [locationScorer], }) expect(result.scores['location-accuracy']).toBe(1) }) }) ``` ## 다음 단계 - [커스텀 채점자 만들기](https://mastra.zisheng.pro/ko/docs/evals/custom-scorers) 자세히 알아보기 - [기본 제공 채점자](https://mastra.zisheng.pro/ko/docs/evals/built-in-scorers) 살펴보기 - [Memory가 활성화된 Agent](https://mastra.zisheng.pro/ko/docs/evals/evals-with-memory)를 대상으로 채점자 실행하기 - [runEvals API 레퍼런스](https://mastra.zisheng.pro/ko/reference/evals/run-evals) 읽기