Skip to content

Commit

Permalink
Merge pull request #344 from tisnik/unit-test-check-system-prompt-usa…
Browse files Browse the repository at this point in the history
…ge-in-gradio

Unit test for checking system prompt usage in GradIO
  • Loading branch information
tisnik authored Feb 3, 2025
2 parents ee72182 + 6943a19 commit cf22960
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/unit/ui/test_gradio_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cf22960

Please sign in to comment.