openai-api-mock 0.1.28 → 0.1.29

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.
package/dist/index.js CHANGED
@@ -2197,8 +2197,7 @@ function mockOpenAIResponse(force = false, options = {}) {
2197
2197
  if (env !== "development" && !force) {
2198
2198
  return { isActive: false, stopMocking };
2199
2199
  }
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) {
2200
+ nock(OPEN_AI_BASE_URL).post(CHAT_COMPLETIONS_ENDPOINT).delay(latency).reply(function(uri, requestBody) {
2202
2201
  if (logRequests) {
2203
2202
  console.log(`[openai-api-mock] Chat request:`, JSON.stringify(requestBody, null, 2));
2204
2203
  }
@@ -2220,7 +2219,7 @@ function mockOpenAIResponse(force = false, options = {}) {
2220
2219
  return [500, { error: { message: "Internal server error in mock" } }];
2221
2220
  }
2222
2221
  });
2223
- mockWithDelay.post(IMAGE_GENERATIONS_ENDPOINT).reply(function(uri, requestBody) {
2222
+ nock(OPEN_AI_BASE_URL).post(IMAGE_GENERATIONS_ENDPOINT).delay(latency).reply(function(uri, requestBody) {
2224
2223
  if (logRequests) {
2225
2224
  console.log(`[openai-api-mock] Image request:`, JSON.stringify(requestBody, null, 2));
2226
2225
  }