跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

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 example
Usage example的直接链接

import { mastra } from './mastra'

const safety = mastra.getClassifier('safety')

const result = await safety.decide({
state: { content: 'A message to evaluate' },
})

Parameters
Parameters的直接链接

key:

string
The registration key of the classifier to retrieve. This should match a key used when registering classifiers in the Mastra constructor.

Returns
Returns的直接链接

classifier:

Classifier
The Classifier instance associated with the provided key.

Error handling
Error handling的直接链接

This method throws a MastraError with id MASTRA_GET_CLASSIFIER_NOT_FOUND if no classifier is registered under the specified key.

On this page