UNPKG

openai-tokens-count

Version:

OpenAI tokens calculator with function calls, images, and messages in one call

35 lines 883 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatToolContent = exports.isJSONString = exports.tryFormatJSON = void 0; const argument_format_1 = require("./argument-format"); function tryFormatJSON(content) { try { return JSON.parse(content); } catch (ignored) { return null; } } exports.tryFormatJSON = tryFormatJSON; function isJSONString(content) { try { JSON.parse(content); return true; } catch (ignored) { return false; } } exports.isJSONString = isJSONString; function formatToolContent(content) { try { JSON.parse(content); return (0, argument_format_1.formatArguments)(content); } catch (ex) { // error } return content; } exports.formatToolContent = formatToolContent; //# sourceMappingURL=tool-content-format.js.map