openai-api-mock 0.1.26 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2197,8 +2197,8 @@ function mockOpenAIResponse(force = false, options = {}) {
2197
2197
  if (env !== "development" && !force) {
2198
2198
  return { isActive: false, stopMocking };
2199
2199
  }
2200
- latency > 0 ? nock.defaults({ delayConnection: latency }) : null;
2201
- nock(OPEN_AI_BASE_URL).post(CHAT_COMPLETIONS_ENDPOINT).reply(function(uri, requestBody) {
2200
+ const mockWithDelay = latency > 0 ? nock(OPEN_AI_BASE_URL).delay(latency) : nock(OPEN_AI_BASE_URL);
2201
+ mockWithDelay.post(CHAT_COMPLETIONS_ENDPOINT).reply(function(uri, requestBody) {
2202
2202
  if (logRequests) {
2203
2203
  console.log(`[openai-api-mock] Chat request:`, JSON.stringify(requestBody, null, 2));
2204
2204
  }
@@ -2220,7 +2220,7 @@ function mockOpenAIResponse(force = false, options = {}) {
2220
2220
  return [500, { error: { message: "Internal server error in mock" } }];
2221
2221
  }
2222
2222
  });
2223
- nock(OPEN_AI_BASE_URL).post(IMAGE_GENERATIONS_ENDPOINT).reply(function(uri, requestBody) {
2223
+ mockWithDelay.post(IMAGE_GENERATIONS_ENDPOINT).reply(function(uri, requestBody) {
2224
2224
  if (logRequests) {
2225
2225
  console.log(`[openai-api-mock] Image request:`, JSON.stringify(requestBody, null, 2));
2226
2226
  }
@@ -2262,4 +2262,4 @@ export {
2262
2262
  mockOpenAIResponse,
2263
2263
  stopMocking
2264
2264
  };
2265
- //# sourceMappingURL=index.es.js.map
2265
+ //# sourceMappingURL=index.js.map