MCPcopy Create free account
hub / github.com/openai/plugins / parseUsageContent

Function parseUsageContent

plugins/plugin-eval/src/core/observed-usage.js:145–168  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

143}
144
145function parseUsageContent(content) {
146 const trimmed = content.trim();
147 if (!trimmed) {
148 return [];
149 }
150
151 if (trimmed.startsWith("[")) {
152 return [JSON.parse(trimmed)];
153 }
154
155 if (trimmed.startsWith("{")) {
156 try {
157 return [JSON.parse(trimmed)];
158 } catch {
159 // Fall through to JSONL parsing when the file contains multiple JSON objects.
160 }
161 }
162
163 return trimmed
164 .split(/\r?\n/)
165 .map((line) => line.trim())
166 .filter(Boolean)
167 .map((line) => JSON.parse(line));
168}
169
170async function loadSnapshotsFromFile(filePath) {
171 const resolvedPath = path.resolve(filePath);

Callers 1

loadSnapshotsFromFileFunction · 0.85

Calls 2

mapMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected