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

const client = new PiClient({
  apiKey: 'My API Key',
});

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);
{
  "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

Examples:

"Tell me something different"

llm_output
string
required

The output to score

Examples:

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

scoring_spec
Question · object[]
required

Either a scoring spec or a list of questions to score

Examples:
[
{ "question": "Is this response truthful?" },
{ "question": "Is this response relevant?" }
]
aggregation_method
enum<string>

The strategy to combine the individual question scores to get the total score. Defaults to HARMONIC_MEAN.

Available options:
ARITHMETIC_MEAN,
GEOMETRIC_MEAN,
HARMONIC_MEAN
kwargs
object

Optional additional parameters (keyword arguments)

Examples:
{ "any_param": "any_value" }

Response

Successful Response

question_scores
object
required

The score components for each question

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

The total score of the scoring spec

Examples:

0.4