|
22 | 22 | from httpx import ASGITransport, AsyncClient |
23 | 23 |
|
24 | 24 | import litserve as ls |
| 25 | +from litserve.specs.openai import OpenAISpec |
25 | 26 | from litserve.specs.openai_embedding import OpenAIEmbeddingSpec |
26 | 27 | from litserve.test_examples.openai_embedding_spec_example import ( |
27 | 28 | TestEmbedAPI, |
@@ -50,6 +51,22 @@ async def test_openai_embedding_spec_with_single_input(openai_embedding_request_ |
50 | 51 | assert len(resp.json()["data"]) == 1, "Length of data should be 1" |
51 | 52 | assert len(resp.json()["data"][0]["embedding"]) == 768, "Embedding length should be 768" |
52 | 53 |
|
| 54 | +@pytest.mark.asyncio |
| 55 | +async def test_openai_embedding_spec_with_multi_endpoint(openai_embedding_request_data): |
| 56 | + spec_openai = OpenAISpec() |
| 57 | + spec_embedding = OpenAIEmbeddingSpec() |
| 58 | + server = ls.LitServer([TestEmbedAPI(spec=spec_openai),TestEmbedAPI(spec=spec_embedding)]) |
| 59 | + with wrap_litserve_start(server) as server: |
| 60 | + async with LifespanManager(server.app) as manager, AsyncClient( |
| 61 | + transport=ASGITransport(app=manager.app), base_url="http://test" |
| 62 | + ) as ac: |
| 63 | + resp = await ac.post("/v1/embeddings", json=openai_embedding_request_data, timeout=10) |
| 64 | + assert resp.status_code == 200, "Status code should be 200" |
| 65 | + assert resp.json()["object"] == "list", "Object should be list" |
| 66 | + assert resp.json()["data"][0]["index"] == 0, "Index should be 0" |
| 67 | + assert len(resp.json()["data"]) == 1, "Length of data should be 1" |
| 68 | + assert len(resp.json()["data"][0]["embedding"]) == 768, "Embedding length should be 768" |
| 69 | + |
53 | 70 |
|
54 | 71 | @pytest.mark.asyncio |
55 | 72 | async def test_openai_embedding_spec_with_multiple_inputs(openai_embedding_request_data_array): |
|
0 commit comments