From 0a36aca5f2b1a623b1410641e4e5296a720d9045 Mon Sep 17 00:00:00 2001 From: Eric Apgar Date: Thu, 16 Apr 2026 09:58:27 -0500 Subject: [PATCH 1/2] Updated test for image to server. --- tests/test_server.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/test_server.py b/tests/test_server.py index 4db6d9c..730282c 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -19,8 +19,10 @@ import pytest import requests +from PIL import Image as PillowImage import llm_server +from llm_server.helper.helper import encode_image MODEL_CACHE = os.environ.get('LLM_MODEL_CACHE') @@ -36,7 +38,7 @@ def server(): s.stop() -@pytest.fixture(scope='module') +@pytest.fixture(scope='function') def server_with_model(): if not MODEL_CACHE: pytest.skip('LLM_MODEL_CACHE environment variable not set.') @@ -47,6 +49,7 @@ def server_with_model(): s.start() time.sleep(1) # Allow uvicorn to finish starting. yield s + s.del_model(tag='gpt') # Free GPU memory before teardown. s.stop() @@ -63,3 +66,36 @@ def test_ask(server_with_model): data = response.json() assert isinstance(data['text'], str) assert len(data['text']) > 0 + + +@pytest.fixture(scope='module') +def server_with_multimodal_model(): + if not MODEL_CACHE: + pytest.skip('LLM_MODEL_CACHE environment variable not set.') + s = llm_server.Server() + s.set_host(ip_address='127.0.0.1', port=8003) + s.add_model(tag='phi4', name='microsoft/Phi-4-multimodal-instruct') + s.load_model(tag='phi4', location=MODEL_CACHE) + s.start() + time.sleep(1) # Allow uvicorn to finish starting. + yield s + s.stop() + + +@pytest.fixture(scope='module') +def red_square_image(): + return PillowImage.new('RGB', (64, 64), color=(255, 0, 0)) + + +def test_ask_with_image(server_with_multimodal_model, red_square_image): + response = requests.post( + 'http://127.0.0.1:8003/ask', + json={ + 'tag': 'phi4', + 'prompt': 'Describe the image.', + 'images': [encode_image(red_square_image)], + }, + timeout=60) + data = response.json() + assert isinstance(data['text'], str) + assert len(data['text']) > 0 From d46d20e778cee091e5ccf09d49cc6dd1b41d5415 Mon Sep 17 00:00:00 2001 From: Eric Apgar Date: Thu, 16 Apr 2026 10:00:27 -0500 Subject: [PATCH 2/2] Updated version. --- pyproject.toml | 2 +- uv.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dbc72d2..25798d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "llm_server" # The pip install . -version = "0.2.0" +version = "0.3.0" description = "Template for repos that are intended to be packaged libraries." readme = "README.md" authors = [{ name = "Eric Apgar" }] diff --git a/uv.lock b/uv.lock index 45941f9..85ec64a 100644 --- a/uv.lock +++ b/uv.lock @@ -472,7 +472,7 @@ source = { git = "https://github.com/EricApgar/llm-conversation#ce9d59af41f4a018 [[package]] name = "llm-server" -version = "0.2.0" +version = "0.3.0" source = { editable = "." } dependencies = [ { name = "fastapi" }, @@ -1285,9 +1285,9 @@ dependencies = [ { name = "typing-extensions" }, ] wheels = [ - { url = "https://download.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:4fc8f67637f4c92b989a07d80ffe755e79a3510ca02ebf23ce66396fb277c88d" }, - { url = "https://download.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:858f0cbcc78d726fea9499eb3464faa98392fa093845a3262209bd226b7844d6" }, - { url = "https://download.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-win_amd64.whl", hash = "sha256:224649fa0ab181ec483cc368e3303dda1760e4ba31bea806b88979f855436aaa" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:4fc8f67637f4c92b989a07d80ffe755e79a3510ca02ebf23ce66396fb277c88d" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:858f0cbcc78d726fea9499eb3464faa98392fa093845a3262209bd226b7844d6" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.10.0%2Bcu130-cp312-cp312-win_amd64.whl", hash = "sha256:224649fa0ab181ec483cc368e3303dda1760e4ba31bea806b88979f855436aaa" }, ] [[package]]