-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change to only serve 1 model per instance
- Loading branch information
Showing
3 changed files
with
76 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,47 @@ | ||
from fastapi.testclient import TestClient | ||
from main import app, default_model_name | ||
|
||
client = TestClient(app) | ||
from main import app, model_name | ||
|
||
|
||
def test_read_healthz(): | ||
response = client.get("/healthz") | ||
assert response.status_code == 200 | ||
with TestClient(app) as client: | ||
response = client.get("/healthz") | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_embedding_str(): | ||
embedding_request = { | ||
"input": "substratus.ai has some great LLM OSS projects for K8s", | ||
"model": default_model_name | ||
} | ||
response = client.post("/v1/embeddings", json=embedding_request) | ||
assert response.status_code == 200 | ||
embedding_response = response.json() | ||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"][0], float) | ||
with TestClient(app) as client: | ||
embedding_request = { | ||
"input": "substratus.ai has some great LLM OSS projects for K8s", | ||
"model": model_name, | ||
} | ||
response = client.post("/v1/embeddings", json=embedding_request) | ||
assert response.status_code == 200 | ||
embedding_response = response.json() | ||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"][0], float) | ||
|
||
|
||
def test_embedding_list_str(): | ||
embedding_request = { | ||
"input": ["substratus.ai has some great LLM OSS projects for K8s", "2nd string"], | ||
"model": default_model_name | ||
} | ||
response = client.post("/v1/embeddings", json=embedding_request) | ||
assert response.status_code == 200 | ||
embedding_response = response.json() | ||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"][0], float) | ||
|
||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][1]["embedding"], list) | ||
assert isinstance(embedding_response["data"][1]["embedding"][0], float) | ||
|
||
embedding_1 = embedding_response["data"][0]["embedding"] | ||
embedding_2 = embedding_response["data"][1]["embedding"] | ||
assert embedding_1 != embedding_2 | ||
with TestClient(app) as client: | ||
embedding_request = { | ||
"input": [ | ||
"substratus.ai has some great LLM OSS projects for K8s", | ||
"2nd string", | ||
], | ||
"model": model_name, | ||
} | ||
response = client.post("/v1/embeddings", json=embedding_request) | ||
assert response.status_code == 200 | ||
embedding_response = response.json() | ||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"], list) | ||
assert isinstance(embedding_response["data"][0]["embedding"][0], float) | ||
|
||
assert isinstance(embedding_response["data"], list) | ||
assert isinstance(embedding_response["data"][1]["embedding"], list) | ||
assert isinstance(embedding_response["data"][1]["embedding"][0], float) | ||
|
||
embedding_1 = embedding_response["data"][0]["embedding"] | ||
embedding_2 = embedding_response["data"][1]["embedding"] | ||
assert embedding_1 != embedding_2 |