npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@promptrepo/score

v6.0.7

Published

Calculate confidence scores for OpenAI JSON outputs

Readme

@promptrepo/score

Calculate confidence scores for OpenAI JSON outputs. Transform black box responses into reliable data with granular field-level scoring.

Why @promptrepo/score?

  • 📊 Precise Scoring: Convert OpenAI's logprobs into confidence metrics for each JSON field
  • 🚀 Simple Integration: Works directly with OpenAI's completion and chat endpoints
  • Lightweight: Zero dependencies for scoring logic

Installation

npm install @promptrepo/score
npm install openai  # Required for OpenAI API examples

Model Requirements

This package requires OpenAI models that support both logprobs and structured JSON output:

  • For chat completion: gpt-3.5-turbo or gpt-4 or gpt-4o
  • For completion: gpt-3.5-turbo-instruct

Basic Usage

With OpenAI Chat Completion

import { calculateConfidenceScores } from '@promptrepo/score';
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'sk-...' // Replace with your OpenAI API key
});

// Make an API call
const response = await openai.chat.completions.create({
    model: "gpt-3.5-turbo",
    messages: [
        {
            role: "system",
            content: "You are a helpful assistant that returns JSON responses."
        },
        {
            role: "user",
            content: "Extract product information from: 'Product: Premium Widget, Price: $29.99'"
        }
    ],
    response_format: { type: "json_object" },
    logprobs: true,
    max_tokens: 500,
    temperature: 0
});

// Parse JSON response
const jsonOutput = JSON.parse(response.choices[0].message.content);

// Raw OpenAI output
console.log('OpenAI output:', jsonOutput);
// {
//   "Product name": "Premium Widget",
//   "Price": "29.99"
// }

// Calculate confidence scores
const result = calculateConfidenceScores(jsonOutput, response.choices[0].logprobs.content);

// @promptrepo/score output with confidence scores
console.log('Confidence scores:', result);
// {
//   "Product name": { value: "Premium Widget", score: 0.95 },
//   "Price": { value: "29.99", score: 0.92 }
// }

Nested Structures

import { calculateConfidenceScores } from '@promptrepo/score';
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'sk-...' // Replace with your OpenAI API key
});

// Make an API call
const response = await openai.chat.completions.create({
    model: "gpt-3.5-turbo",
    messages: [
        {
            role: "system",
            content: "You are a helpful assistant that returns JSON responses with nested product information."
        },
        {
            role: "user",
            content: "Extract detailed product information from: 'Product: Premium Widget, Price: $29.99, Weight: 1.5kg, Dimensions: 10x20x30cm'"
        }
    ],
    response_format: { type: "json_object" },
    logprobs: true,
    max_tokens: 500,
    temperature: 0
});

// Parse JSON response
const jsonOutput = JSON.parse(response.choices[0].message.content);

// Raw OpenAI output
console.log('OpenAI output:', jsonOutput);
// {
//   product: {
//     details: {
//       name: "Premium Widget",
//       price: "29.99"
//     },
//     specifications: {
//       weight: "1.5kg",
//       dimensions: "10x20x30cm"
//     }
//   }
// }

// Calculate confidence scores
const result = calculateConfidenceScores(jsonOutput, response.choices[0].logprobs.content);

// @promptrepo/score output with confidence scores
console.log('Confidence scores:', result);
// {
//   product: {
//     value: {
//       details: {
//         value: {
//           name: { value: "Premium Widget", score: 0.95 },
//           price: { value: "29.99", score: 0.92 }
//         },
//         score: 0.93
//       },
//       specifications: {
//         value: {
//           weight: { value: "1.5kg", score: 0.94 },
//           dimensions: { value: "10x20x30cm", score: 0.91 }
//         },
//         score: 0.92
//       }
//     },
//     score: 0.92
//   }
// }