UNPKG

@aj-archipelago/cortex

Version:

Cortex is a GraphQL API for AI. It provides a simple, extensible interface for using AI services from OpenAI, Azure and others.

25 lines (21 loc) 580 B
// fulfill a task with an timeout const fulfillWithTimeout = (promise, timeout) => { return new Promise((resolve, reject) => { const timeoutId = setTimeout(() => { reject(new Error(`Request timed out after ${timeout} seconds!`)); }, timeout * 1000); promise.then( (res) => { clearTimeout(timeoutId); resolve(res); }, (err) => { clearTimeout(timeoutId); reject(err); } ); }); }; export { fulfillWithTimeout };