> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # getScorerById() `getScorerById()` メソッドは、登録キーではなく Scorer の `id` プロパティ(見つからない場合は `name` プロパティ)を検索して取得します。Scorer の id は分かっていても、Mastra インスタンスへの登録方法が分からない場合に便利です。 ## 使用例 ```typescript import { mastra } from './mastra' // Get a scorer by its id property const relevancyScorer = mastra.getScorerById('answer-relevancy-scorer') 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, }, }, }) ``` ## パラメーター **id** (`string`): 取得する Scorer の id プロパティ。createScorer() で Scorer を作成したときに指定した 'id' フィールドと一致する必要があります。見つからない場合は 'name' プロパティも検索します。 ## 戻り値 **scorer** (`MastraScorer`): 一致する id(または name)プロパティを持つ MastraScorer インスタンス。 ## エラー処理 次の場合、このメソッドは `MastraError` をスローします。 - 指定した id の Scorer が見つからない - Mastra インスタンスに Scorer が登録されていない ```typescript try { const scorer = mastra.getScorerById('non-existent-scorer') } catch (error) { if (error.id === 'MASTRA_GET_SCORER_BY_ID_NOT_FOUND') { console.log('Scorer with that id not found') } } ``` ## 関連項目 - [getScorer()](https://mastra.zisheng.pro/ja/reference/core/getScorer): 登録キーで Scorer を取得 - [listScorers()](https://mastra.zisheng.pro/ja/reference/core/listScorers): 登録済みのすべての Scorer を取得 - [createScorer()](https://mastra.zisheng.pro/ja/reference/evals/create-scorer): ID を指定した Scorer の作成方法