getClassifier()
The getClassifier() method retrieves a classifier that was registered with the Mastra instance using its registration key. It throws an error if the requested classifier isn't found.
Usage exampleDirect link to Usage example
import { mastra } from './mastra'
const safety = mastra.getClassifier('safety')
const result = await safety.evaluate({
state: { content: 'A message to evaluate' },
})
ParametersDirect link to Parameters
key:
string
The registration key of the classifier to retrieve. This should match a key used when registering classifiers in the Mastra constructor.
ReturnsDirect link to Returns
classifier:
Classifier
The Classifier instance associated with the provided key.
Error handlingDirect link to Error handling
This method throws a MastraError with id MASTRA_GET_CLASSIFIER_NOT_FOUND if no classifier is registered under the specified key.
RelatedDirect link to Related
- getClassifierById(): Get a classifier by its id property
- listClassifiers(): Get all registered classifiers
- Classifier