import PiClient from 'withpi';
const client = new PiClient({
apiKey: 'My API Key',
});
const response = await client.search.queryClassifier.classify({
classes: [
{ description: 'Questions seeking objective, verifiable information or facts', label: 'factual' },
{
description: 'Questions asking for subjective judgments, preferences, or personal views',
label: 'opinion',
},
{ description: 'Questions about how to perform tasks or follow specific processes', label: 'procedural' },
],
queries: [
'What is the capital of France?',
'How do I feel about the current political climate?',
'What steps should I follow to bake a chocolate cake?',
],
});
console.log(response.results);
{
"results": [
{
"prediction": "<string>",
"probabilities": [
{
"label": "<string>",
"score": 123
}
],
"query": "<string>"
}
]
}
Classifies queries into provided classes based on a custom taxonomy.
import PiClient from 'withpi';
const client = new PiClient({
apiKey: 'My API Key',
});
const response = await client.search.queryClassifier.classify({
classes: [
{ description: 'Questions seeking objective, verifiable information or facts', label: 'factual' },
{
description: 'Questions asking for subjective judgments, preferences, or personal views',
label: 'opinion',
},
{ description: 'Questions about how to perform tasks or follow specific processes', label: 'procedural' },
],
queries: [
'What is the capital of France?',
'How do I feel about the current political climate?',
'What steps should I follow to bake a chocolate cake?',
],
});
console.log(response.results);
{
"results": [
{
"prediction": "<string>",
"probabilities": [
{
"label": "<string>",
"score": 123
}
],
"query": "<string>"
}
]
}
Successful Response
The response is of type object
.