POST
/
search
/
query_classifier
/
classify
JavaScript
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>"
    }
  ]
}

Authorizations

x-api-key
string
header
required

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.