langsmith
Version:
Client library to connect to the LangSmith Observability and Evaluation Platform.
29 lines (28 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertAnthropicUsageToInputTokenDetails = void 0;
const convertAnthropicUsageToInputTokenDetails = (usage) => {
const result = {};
if (usage.cache_creation != null &&
typeof usage.cache_creation === "object") {
const cacheCreation = usage.cache_creation;
if (typeof cacheCreation.ephemeral_5m_input_tokens === "number") {
result.ephemeral_5m_input_tokens =
cacheCreation.ephemeral_5m_input_tokens;
}
if (typeof cacheCreation.ephemeral_1h_input_tokens === "number") {
result.ephemeral_1hr_input_tokens =
cacheCreation.ephemeral_1h_input_tokens;
}
// If cache_creation not returned (no beta header passed),
// fallback to assuming 5m cache tokens
}
else if (typeof usage.cache_creation_input_tokens === "number") {
result.ephemeral_5m_input_tokens = usage.cache_creation_input_tokens;
}
if (typeof usage.cache_read_input_tokens === "number") {
result.cache_read = usage.cache_read_input_tokens;
}
return result;
};
exports.convertAnthropicUsageToInputTokenDetails = convertAnthropicUsageToInputTokenDetails;