Lightning-AI / Lightning-AI/LitServe

Run a mix of async and non-async methods in LitAPI like FastAPI

Open
#490 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

## 🚀 Feature

LitAPI can automatically identify if the function is a coroutine and run accordingly.

```py
class MyAPI(ls.LitAPI):
def predict(self, x):
return y

async def encode_response(self, out):
return {"output": out}
```

### Motivation

### Pitch

### Alternatives

### Additional context

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 at the LitAPI request-dispatch entry point and inspect how methods are currently invoked. Confirm how coroutine detection should support the shown sync predict and async encode_response combination, then add coverage for mixed async and non-async methods and verify both paths complete correctly.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.