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/__tests__/mock_delay.test.js +28 -0
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +4 -5
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
|
-
|
|
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
|
-
|
|
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
|
}
|