Skip to content

Conversation

@rongfengliang
Copy link
Contributor

What does this PR do?

Fixes # (issue).

The OpenAIEmbeddingSpec currently only checks if server.lit_api is set to one. However, LitServe now supports multiple Endpoint , so this PR adds the necessary checks for multiple Endpoint.

@codecov
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85%. Comparing base (c4abf01) to head (2db66e1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #568   +/-   ##
===================================
  Coverage    85%    85%           
===================================
  Files        38     38           
  Lines      2982   2990    +8     
===================================
+ Hits       2538   2546    +8     
  Misses      444    444           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aniketmaurya
Copy link
Collaborator

aniketmaurya commented Jul 4, 2025

hi @rongfengliang, thank you for creating the PR! Moving with version 0.3.0, we are going to change how we pass specs to the server so one LitAPI will connect to a single spec.

New:

api = EmbeddingLitAPI(spec=ls.OpenAIEmebeddingSpec())
server = ls.Server(api)

Old:

api = EmbeddingLitAPI()
server = ls.Server(api, spec=ls.OpenAIEmebeddingSpec())

@rongfengliang
Copy link
Contributor Author

rongfengliang commented Jul 4, 2025

@aniketmaurya that's true, but currently OpenAIEmbeddingSpec in setup check use server.lit_api , lit_api maybe a list, this pr will check if server.lit_api is one or multi

    def setup(self, server: "LitServer"):
        from litserve import LitAPI

        super().setup(server)

        lit_api = server.lit_api  # if lit_api is a list  below lit_api.predict will throw one exception 
        if inspect.isgeneratorfunction(lit_api.predict):

also Old design maybe not very good. LitAPI use LitSpec maybe LitSpec also add LitAPI instance so ,LitSpec will not use server instance, this will be better for checking some functions (like OpenAIEmbeddingSpec check async or sync code )

@aniketmaurya
Copy link
Collaborator

@rongfengliang cool let's do this for now. Can you please add a unit test here too? Maybe pass litapi both as a list and a single instance to LitServe and assert it works both time.

@rongfengliang rongfengliang requested a review from Borda July 4, 2025 13:21
@rongfengliang
Copy link
Contributor Author

@aniketmaurya I had added the Unit test

@aniketmaurya aniketmaurya merged commit 23c05fc into Lightning-AI:main Jul 7, 2025
21 checks passed
@bhimrazy
Copy link
Collaborator

bhimrazy commented Jul 7, 2025

I was thinking a bit more about this, and something came to mind — ideally, it might be cleaner if the spec only needs to check the specific LitAPI instance it's attached to, rather than handling a list. Maybe this could be abstracted better via the connector.

cc: @aniketmaurya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants