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: {
      description: "Write a children's story communicating a simple life lesson.",
      dimensions: [
        {
          description: 'dimension1 description',
          label: 'dimension1',
          sub_dimensions: [
            { description: 'subdimension1 description', label: 'subdimension1', scoring_type: 'PI_SCORER' },
          ],
        },
      ],
      name: 'Sample Scoring Spec',
    },
  });

  console.log(scoringSystemMetrics.dimension_scores);
}

main();
{
  "dimension_scores": {
    "dimension1": {
      "subdimension_scores": {
        "subdimension1": 0.5
      },
      "total_score": 0.5
    }
  },
  "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
object
required

The scoring spec to score

Response

200
application/json
Successful Response
dimension_scores
object
required

The score components for each dimension

Example:
{
  "dimension1": {
    "subdimension_scores": { "subdimension1": 0.5 },
    "total_score": 0.5
  }
}
total_score
number
required

The total score of the scoring spec

Example:

0.4