> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # getScorer() `getScorer()` メソッドは、Mastra インスタンスに登録された特定の Scorer を登録キーで取得します。このメソッドは型安全に Scorer へアクセスでき、要求した Scorer が見つからない場合はエラーをスローします。 ## 使用例 ```typescript import { mastra } from './mastra' // Get a specific scorer by key const relevancyScorer = mastra.getScorer('relevancyScorer') const weatherAgent = mastra.getAgent('weatherAgent') // Use the scorer to evaluate an AI output await weatherAgent.generate('What is the weather in Rome', { scorers: { answerRelevancy: { scorer: relevancyScorer, }, }, }) ``` ## パラメーター **key** (`string`): 取得する Scorer の登録キー。Mastra のコンストラクターで Scorer を登録したときに使用したキーと一致する必要があります。 ## 戻り値 **scorer** (`MastraScorer`): 指定したキーに対応する MastraScorer インスタンス。 ## エラー処理 次の場合、このメソッドは `MastraError` をスローします。 - 指定したキーの Scorer が見つからない - Mastra インスタンスに Scorer が登録されていない ```typescript try { const scorer = mastra.getScorer('nonExistentScorer') } catch (error) { if (error.id === 'MASTRA_GET_SCORER_NOT_FOUND') { console.log('Scorer not found, using default evaluation') } } ``` ## 関連項目 - [listScorers()](https://mastra.zisheng.pro/ja/reference/core/listScorers): 登録済みのすべての Scorer を取得 - [getScorerById()](https://mastra.zisheng.pro/ja/reference/core/getScorerById): id プロパティで Scorer を取得 - [カスタム Scorer](https://mastra.zisheng.pro/ja/docs/evals/custom-scorers): カスタム Scorer の作成方法