polly3d / mockai

MockAI is a mock server for OpenAI's API. It allows you to simulate Chat Completions API responses for development and testing purposes.
MIT License
42 stars 16 forks source link

HTTP 413 Payload Too Large when sending image inline #14

Closed ctrahey closed 4 days ago

ctrahey commented 5 days ago

I'm using MockAI for a call that includes image inline. The call works toward OpenAI. I'm not sure what the limit should be, but hopefully this project can simply discard and ignore the input?

HTTP Request: POST http://mock_third_party:8000/v1/chat/completions "HTTP/1.1 413 Payload Too Large

Let me know if you need more info about it. By my napkin math, my request should be around 70MB

ctrahey commented 5 days ago

This is what gets logged.


mock_third_party-1  | PayloadTooLargeError: request entity too large
mock_third_party-1  |     at readStream (/app/node_modules/raw-body/index.js:156:17)
mock_third_party-1  |     at getRawBody (/app/node_modules/raw-body/index.js:109:12)
mock_third_party-1  |     at read (/app/node_modules/body-parser/lib/read.js:79:3)
mock_third_party-1  |     at jsonParser (/app/node_modules/body-parser/lib/types/json.js:135:5)
mock_third_party-1  |     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
mock_third_party-1  |     at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13)
mock_third_party-1  |     at /app/node_modules/express/lib/router/index.js:286:9
mock_third_party-1  |     at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12)
mock_third_party-1  |     at next (/app/node_modules/express/lib/router/index.js:280:10)
mock_third_party-1  |     at expressInit (/app/node_modules/express/lib/middleware/init.js:40:5)
polly3d commented 4 days ago

Thank you for using this repo. I don't have a large dataset to reproduce the bug. However, I found a very simple solution that might help you. If this is a major requirement, I can modify the code accordingly.

Error: request entity too large

app.use(express.json({limit: '50mb'}));

Hope it helps.