Skip to content

fix: OpenAIEmbeddingSpec setup check for multi endpoint - #568

Merged
aniketmaurya merged 14 commits into
Lightning-AI:mainfrom
rongfengliang:patch-2
Jul 7, 2025
Merged

fix: OpenAIEmbeddingSpec setup check for multi endpoint#568
aniketmaurya merged 14 commits into
Lightning-AI:mainfrom
rongfengliang:patch-2

Conversation

@rongfengliang

Copy link
Copy Markdown
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

codecov Bot commented Jul 4, 2025

Copy link
Copy Markdown

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

aniketmaurya commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator

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

rongfengliang commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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.

Comment thread src/litserve/specs/openai_embedding.py Outdated
@rongfengliang
rongfengliang requested a review from Borda July 4, 2025 13:21
@rongfengliang

Copy link
Copy Markdown
Contributor Author

@aniketmaurya I had added the Unit test

Comment thread src/litserve/test_examples/openai_embedding_spec_example.py Outdated
Comment thread tests/unit/test_openai_embedding.py Outdated
Comment thread tests/unit/test_openai_embedding.py Outdated
Comment thread tests/unit/test_openai_embedding.py
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Comment thread tests/unit/test_openai_embedding.py Outdated
Comment thread tests/unit/test_openai_embedding.py
Comment thread tests/unit/test_openai_embedding.py Outdated
Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
@aniketmaurya
aniketmaurya merged commit 23c05fc into Lightning-AI:main Jul 7, 2025
21 checks passed
@bhimrazy

bhimrazy commented Jul 7, 2025

Copy link
Copy Markdown
Collaborator

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