Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 26, 2024
1 parent 787b37f commit 7911c33
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ async def test_openai_spec(openai_request_data):
resp = await ac.post("/v1/chat/completions", json=openai_request_data, timeout=10)
assert resp.status_code == 200, "Status code should be 200"

assert (
resp.json()["choices"][0]["message"]["content"] == "This is a generated output"
), "LitAPI predict response should match with the generated output"
assert resp.json()["choices"][0]["message"]["content"] == "This is a generated output", (
"LitAPI predict response should match with the generated output"
)


# OpenAIWithUsage
Expand Down Expand Up @@ -90,9 +90,9 @@ async def test_openai_spec_with_image(openai_request_data_with_image):
resp = await ac.post("/v1/chat/completions", json=openai_request_data_with_image, timeout=10)
assert resp.status_code == 200, "Status code should be 200"

assert (
resp.json()["choices"][0]["message"]["content"] == "This is a generated output"
), "LitAPI predict response should match with the generated output"
assert resp.json()["choices"][0]["message"]["content"] == "This is a generated output", (
"LitAPI predict response should match with the generated output"
)


@pytest.mark.asyncio
Expand All @@ -103,9 +103,9 @@ async def test_override_encode(openai_request_data):
resp = await ac.post("/v1/chat/completions", json=openai_request_data, timeout=10)
assert resp.status_code == 200, "Status code should be 200"

assert (
resp.json()["choices"][0]["message"]["content"] == "This is a custom encoded output"
), "LitAPI predict response should match with the generated output"
assert resp.json()["choices"][0]["message"]["content"] == "This is a custom encoded output", (
"LitAPI predict response should match with the generated output"
)


@pytest.mark.asyncio
Expand All @@ -116,9 +116,9 @@ async def test_openai_spec_with_tools(openai_request_data_with_tools):
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac:
resp = await ac.post("/v1/chat/completions", json=openai_request_data_with_tools, timeout=10)
assert resp.status_code == 200, "Status code should be 200"
assert (
resp.json()["choices"][0]["message"]["content"] == ""
), "LitAPI predict response should match with the generated output"
assert resp.json()["choices"][0]["message"]["content"] == "", (
"LitAPI predict response should match with the generated output"
)
assert resp.json()["choices"][0]["message"]["tool_calls"] == [
{
"id": "call_1",
Expand Down Expand Up @@ -191,9 +191,9 @@ async def test_oai_prepopulated_context(openai_request_data):
with wrap_litserve_start(server) as server:
async with LifespanManager(server.app) as manager, AsyncClient(app=manager.app, base_url="http://test") as ac:
resp = await ac.post("/v1/chat/completions", json=openai_request_data, timeout=10)
assert (
resp.json()["choices"][0]["message"]["content"] == "This is a"
), "OpenAISpec must return only 3 tokens as specified using `max_tokens` parameter"
assert resp.json()["choices"][0]["message"]["content"] == "This is a", (
"OpenAISpec must return only 3 tokens as specified using `max_tokens` parameter"
)


class WrongLitAPI(ls.LitAPI):
Expand Down

0 comments on commit 7911c33

Please sign in to comment.