UNPKG

ai-utils.js

Version:

Build AI applications, chatbots, and agents with JavaScript and TypeScript.

39 lines (38 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cost = void 0; class Cost { constructor({ costInMillicents, hasUnknownCost, callsWithUnknownCost, }) { Object.defineProperty(this, "costInMillicents", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "hasUnknownCost", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "callsWithUnknownCost", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.costInMillicents = costInMillicents; this.hasUnknownCost = hasUnknownCost; this.callsWithUnknownCost = callsWithUnknownCost; } get costInCent() { return this.costInMillicents / 1000; } get costInDollar() { return this.costInCent / 100; } formatAsDollarAmount({ decimals = 2 } = {}) { return `$${this.costInDollar.toFixed(decimals)}`; } } exports.Cost = Cost;