Lightning-AI / Lightning-AI/LitServe

Allow to pass `default_response_class` e.g. `ORJSONResponse` to LitServe server

Open
#436 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement won't fix
Dominant language
Python
Stars
3.9k
Forks
304
Avg merge
3d 13h
Merged PRs (30d)
6

Description

----

## 🚀 Feature

Allow to pass `default_response_class` e.g. `ORJSONResponse` downstream to the underlying `FastAPI` app.

### Motivation

I really love LitServe, but one thing that I feel is missing is the ability to set the default response class.
After some research and informal experiments with the [orjson project](https://github.com/ijl/orjson) I experienced certain efficiency gains that I'd like to carry over to my LitServe projects.
Do you think it would be worth it to allow for such downstream param passing? If so, I'd be happy to submit a PR :)

### Pitch

Passing custom response classes to the `FastAPI` like `ORJSONResponse` might be a convenient feature with potential of speeding up the serialization and deserialization of JSON.

### Additional context

This approach is also referenced in `FastAPI` docstrings:
https://github.com/fastapi/fastapi/blob/b0215699137c41a96c57f650640cb9db1c25314a/fastapi/applications.py#L369

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating where LitServe constructs its underlying FastAPI app and compare the `default_response_class` parameter in FastAPI's linked `applications.py`. Done means the server accepts a custom response class such as `ORJSONResponse` and passes it to the underlying FastAPI app.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.