From 6943a195c8626d7fda86616816f2f7f631bfbfe7 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 3 Feb 2025 08:42:17 +0100 Subject: [PATCH] Unit test for checking system prompt usage in GradIO --- tests/unit/ui/test_gradio_ui.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/ui/test_gradio_ui.py b/tests/unit/ui/test_gradio_ui.py index ff7f1742..d30fe0f1 100644 --- a/tests/unit/ui/test_gradio_ui.py +++ b/tests/unit/ui/test_gradio_ui.py @@ -120,6 +120,21 @@ def test_chat_ui_handler_use_with_provider(caplog): assert "Using provider: PROVIDER" in captured_out +def test_chat_ui_handler_with_system_prompt(caplog): + """Test the UI handler for proper REST API response when system prompt is setup.""" + ok_response = requests.Response() + ok_response.status_code = requests.codes.ok + ok_response.json = lambda: {"response": "this is response"} + + with patch("ols.src.ui.gradio_ui.requests.post", return_value=ok_response): + ui = GradioUI() + ret = ui.chat_ui("prompt", [], True, model="MODEL", system_prompt="xyzzy") + assert ret == "this is response" + + captured_out = caplog.text + assert "Using system prompt: xyzzy" in captured_out + + def test_chat_ui_handler_use_with_model(caplog): """Test the UI handler for proper REST API response when model is setup.""" ok_response = requests.Response()