@openai/agents-openai
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
41 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeInstructions = normalizeInstructions;
exports.searchParamsToAuthHeaderQuery = searchParamsToAuthHeaderQuery;
exports.toRequestUsageEntry = toRequestUsageEntry;
const agents_core_1 = require("@openai/agents-core");
function normalizeInstructions(instructions) {
if (typeof instructions === 'string') {
return instructions.trim() === '' ? undefined : instructions;
}
return undefined;
}
function searchParamsToAuthHeaderQuery(searchParams) {
const query = {};
let hasEntries = false;
for (const [key, value] of searchParams.entries()) {
hasEntries = true;
const existingValue = query[key];
if (typeof existingValue === 'undefined') {
query[key] = value;
}
else if (Array.isArray(existingValue)) {
existingValue.push(value);
}
else {
query[key] = [existingValue, value];
}
}
return hasEntries ? query : undefined;
}
function toRequestUsageEntry(usage, endpoint) {
return new agents_core_1.RequestUsage({
inputTokens: usage?.input_tokens ?? 0,
outputTokens: usage?.output_tokens ?? 0,
totalTokens: usage?.total_tokens ?? 0,
inputTokensDetails: { ...usage?.input_tokens_details },
outputTokensDetails: { ...usage?.output_tokens_details },
endpoint,
});
}
//# sourceMappingURL=responsesUtils.js.map