POST
/
scoring_system
/
score
import PiClient from 'withpi';

const client = new PiClient({
  apiKey: process.env['WITHPI_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const scoringSystemMetrics = await client.scoringSystem.score({
    llm_input: 'Tell me something different',
    llm_output: 'The lazy dog was jumped over by the quick brown fox',
    scoring_spec: [{ question: 'Is this response truthful?' }, { question: 'Is this response relevant?' }],
  });

  console.log(scoringSystemMetrics.total_score);
}

main();
{
  "dimension_scores": {},
  "question_scores": {
    "Is the response relevant?": 0.5,
    "Is the response truthful?": 0.89
  },
  "total_score": 0.4
}

Authorizations

x-api-key
string
header
required

Body

application/json
llm_input
string
required

The input to score

Example:

"Tell me something different"

llm_output
string
required

The output to score

Example:

"The lazy dog was jumped over by the quick brown fox"

scoring_spec
required

Either a scoring spec or a list of questions to score

Example:
[
  {
    "is_lower_score_desirable": false,
    "question": "Is this response truthful?"
  },
  {
    "is_lower_score_desirable": false,
    "question": "Is this response relevant?"
  }
]
kwargs
object

Optional additional parameters (keyword arguments)

Example:
{ "any_param": "any_value" }

Response

200
application/json
Successful Response
dimension_scores
object
required
deprecated

The score components for each dimension

question_scores
object
required

The score components for each question

Example:
{
  "Is the response relevant?": 0.5,
  "Is the response truthful?": 0.89
}
total_score
number
required

The total score of the scoring spec

Example:

0.4