UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

10 lines (9 loc) • 417 B
export const isExactCount = (v) => Number.isSafeInteger(v) && v >= 0; export function reasoningTokensOf(output, ...spellings) { const claimed = spellings.find((count) => count !== undefined); if (claimed === undefined) return { unreadable: false }; if (!isExactCount(claimed) || claimed > (output ?? 0)) return { unreadable: true }; return { reasoning: claimed, unreadable: false }; }