> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # 평가자 및 득점자 평가 API는 업데이트된 명명 규칙 및 구성 요구 사항을 갖춘 새로운 채점 시스템에 통합되었습니다. ## 변경됨 ### `getScorers`에게`listScorers` `getScorers()` 메서드의 이름이 `listScorers()`로 변경되었습니다. 이 변경은 여러 항목을 가져오는 getter 메서드에 `list` 접두사를 사용하는 API 전반의 명명 규칙과 일치합니다. 마이그레이션하려면 모든 `getScorers()` 호출을 `listScorers()`로 바꾸세요. ```diff - const scorers = mastra.getScorers(); + const scorers = mastra.listScorers(); ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/mastra-plural-apis . ``` ::: ### `runExperiment`에게`runEvals` 평가를 실행한다는 점을 명확히 나타내도록 `runExperiment()` 함수의 이름이 `runEvals()`로 변경되었습니다. 마이그레이션하려면 함수 호출을 `runExperiment`에서 `runEvals`로 업데이트하세요. ```diff - import { createScorer, runExperiment } from '@mastra/core/evals'; + import { createScorer, runEvals } from '@mastra/core/evals'; import { myAgent } from './agents/my-agent'; const scorer = createScorer({ id: 'helpfulness-scorer', // ... }); - const result = await runExperiment({ target: myAgent, scorers: [scorer], data: inputs }); + const result = await runEvals({ target: myAgent, scorers: [scorer], data: inputs }); ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/evals-run-experiment . ``` ::: ### `getScorerByName`에게`getScorerById` `getScorerByName()` 메서드의 이름이 `getScorerById()`로 변경되었습니다. 이제 채점기에는 `name` 대신 `id` 필드가 필요합니다. 이 변경은 엔터티 식별에 `id`를 사용하는 더 광범위한 API 패턴과 일치합니다. 마이그레이션하려면 `name` 대신 `id`를 사용하도록 메서드 호출과 채점기 구성을 업데이트하세요. ```diff const scorer = createScorer({ - name: 'helpfulness-scorer', + id: 'helpfulness-scorer', // ... }); - const scorer = mastra.getScorerByName('helpfulness-scorer'); + const scorer = mastra.getScorerById('helpfulness-scorer'); ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/evals-scorer-by-name . ``` ::: ### 채점기 구성을 `name`에서 `id`로 변경 이제 채점기에는 `name` 대신 `id` 필드가 필요합니다. `name` 필드는 이제 선택 사항입니다. 이 변경으로 다른 Mastra 엔터티와의 일관성이 향상됩니다. 마이그레이션하려면 `id`를 필수 필드로 사용하도록 채점기 정의를 업데이트하세요. ```diff const scorer = createScorer({ - name: 'helpfulness-scorer', + id: 'helpfulness-scorer', + name: 'Helpfulness Scorer', // optional // ... }); ``` ### 스토리지 점수 API`listScoresBy*` pattern 점수 스토리지 API의 이름이 `listScoresBy*` 패턴을 따르도록 변경되었습니다. 이 변경은 더 광범위한 스토리지 API 명명 규칙과 일치합니다. 마이그레이션하려면 새 이름 지정 패턴을 사용하도록 점수 쿼리 방법을 업데이트하세요. ```diff - const scores = await storage.getScores({ scorerName: 'helpfulness-scorer' }); + const scores = await storage.listScoresByScorerId({ + scorerId: 'helpfulness-scorer', + }); // Also available: // - listScoresByRunId // - listScoresByEntityId // - listScoresBySpan ``` ### 사전 구축된 득점 장치를 다음으로 가져옵니다.`scorers/prebuilt` path 사전 구축된 채점기 가져오기 경로가 별도의 `scorers/llm` 및 `scorers/code` 경로에서 단일 `@mastra/evals/scorers/prebuilt` 경로로 통합되었습니다. 이 변경으로 가져오기가 단순해지고 사전 구축된 채점기가 더 명확하게 구성됩니다. 마이그레이션하려면 새 항목을 사용하도록 import 문을 업데이트하세요.`scorers/prebuilt` path. ```diff // LLM-based scorers - import { createHallucinationScorer } from '@mastra/evals/scorers/llm'; - import { createFaithfulnessScorer } from '@mastra/evals/scorers/llm'; + import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt'; + import { createFaithfulnessScorer } from '@mastra/evals/scorers/prebuilt'; // Code-based scorers - import { createContentSimilarityScorer } from '@mastra/evals/scorers/code'; - import { createCompletenessScorer } from '@mastra/evals/scorers/code'; + import { createContentSimilarityScorer } from '@mastra/evals/scorers/prebuilt'; + import { createCompletenessScorer } from '@mastra/evals/scorers/prebuilt'; ``` :::tip\[코드모드] Mastra의 codemod CLI를 사용하여 코드를 자동으로 업데이트할 수 있습니다. ```bash npx @mastra/codemod@latest v1/evals-prebuilt-imports . ``` ::: ### 채점기 메시지 타입을 `UIMessage`에서 `MastraDBMessage`로 변경 이제 채점기의 입력 및 출력 타입은 `UIMessage` 대신 `MastraDBMessage[]`를 사용합니다. 이 변경으로 프레임워크 전반의 일관성을 위해 채점기가 데이터베이스에 저장되는 메시지 형식과 일치합니다. 마이그레이션하려면 `MastraDBMessage` 타입을 사용하고 중첩된 `content` 구조를 통해 메시지 콘텐츠에 접근하도록 채점기 구현을 업데이트하세요. ```diff import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/evals'; - // ScorerRunInputForAgent uses UIMessage[] - const inputMessages: UIMessage[] = run.input.inputMessages; + // ScorerRunInputForAgent now uses MastraDBMessage[] + import type { MastraDBMessage } from '@mastra/core/agent'; + const inputMessages: MastraDBMessage[] = run.input.inputMessages; ``` ### 중첩 형식의 메시지 콘텐츠 구조 이제 Tool 호출과 텍스트 콘텐츠는 메시지의 평면 속성 대신 중첩된 `content` 객체를 통해 접근합니다. 중첩 구조는 데이터베이스 메시지 형식 및 해당 타입과 일치합니다. 마이그레이션하려면 `message.content.toolInvocations`를 통해 Tool 호출에 접근하고 `message.content.content`를 통해 텍스트에 접근하거나 `getTextContentFromMastraDBMessage()` 헬퍼를 사용하세요. ```diff + import { getTextContentFromMastraDBMessage } from '@mastra/evals'; + const run = await scorer.run(testRun); // Accessing text content - const text = message.content; + const text = getTextContentFromMastraDBMessage(message); + // or directly: message.content.content // Accessing tool invocations - const toolCalls = message.toolInvocations; + const toolCalls = message.content.toolInvocations; ``` ## 제거됨 ### 레거시 평가 코드 `@mastra/core`에서 레거시 평가 코드가 제거되었습니다. 여기에는 레거시 평가 메트릭, 채점기/판정 모듈 및 후크 기반 자동 평가 코드가 포함됩니다. 이 변경은 오래된 평가 방식을 제거하여 코드베이스를 단순화합니다. 마이그레이션하려면 `@mastra/core/evals` 또는 `@mastra/evals`의 새 평가/점수 API를 사용하세요. ```diff - // Legacy evals APIs + import { createScorer, runEvals } from '@mastra/core/evals'; + + const scorer = createScorer({ + id: 'my-scorer', + // Use new scorer API + }); ``` ### 대리인`TMetrics` generic parameter `AgentConfig`와 `Agent` 생성자에서 `TMetrics` 제네릭 매개변수가 제거되었습니다. 이제 메트릭과 채점기는 Agent 타입 시스템의 일부가 아니라 채점기 API를 사용해 구성합니다. 이 변경으로 Agent 타입 시그니처가 단순해집니다. 마이그레이션하려면 `TMetrics` 제네릭 매개변수를 제거하고 채점기 API를 사용해 채점기를 구성하세요. ```diff - const agent = new Agent({ + const agent = new Agent({ // ... }); ``` ### 평가 관련 유형 내보내기 `DeprecatedOutputOptions`, `Metric`, 프로세서 옵션 타입을 비롯한 여러 평가 관련 타입 내보내기가 제거되었습니다. 이러한 타입은 이제 내부용이거나 새 채점기 API로 대체되었습니다. 이 변경으로 API 표면적이 줄어듭니다. 마이그레이션하려면 제거된 유형에 대한 참조를 제거하고 새로운 득점자 API를 사용하십시오. ```diff - import type { - DeprecatedOutputOptions, - Metric, - LanguageDetectorOptions, - ModerationOptions, - } from '@mastra/core'; + // Use new scorers API types + import type { Scorer } from '@mastra/core/evals'; ``` ### `createUIMessage`테스트 도우미 `createUIMessage()` 테스트 헬퍼가 제거되고 `createTestMessage()`로 대체되었습니다. 새 헬퍼는 중첩된 콘텐츠 구조를 갖는 `MastraDBMessage` 객체를 생성하고 선택적 Tool 호출을 지원합니다. 이 변경으로 테스트 유틸리티가 새 메시지 형식과 일치합니다. 마이그레이션하려면 `createUIMessage()` 호출을 `createTestMessage()`로 바꾸고 `MastraDBMessage` 타입을 사용하도록 업데이트하세요. ```diff - import { createUIMessage } from '@mastra/evals'; + import { createTestMessage } from '@mastra/evals'; // Creating test messages - const message = createUIMessage({ - id: 'test-1', + const message = createTestMessage({ + id: 'test-1', // optional, defaults to 'test-message' role: 'user', content: 'Hello', toolInvocations: [], // optional }); ```