UNPKG

@ag076810/ai

Version:

Effortlessly integrate AI text and image models in your node applications

26 lines (22 loc) 513 B
// YOLO CODE: https://themaximalist.com/infinityarcade/ function parseJSONFromText(blob) { try { return JSON.parse(blob); } catch (e) { // noop } const lines = blob.split("\n"); for (const line of lines) { if (line[0] == "{") { try { return JSON.parse(line); } catch (e) { // noop } } } throw new Error(`Invalid response: '${blob}'`); } module.exports = { parseJSONFromText, };