Skip to content

Commit

Permalink
Merge pull request #284 from tisnik/system-prompt-ui-widget-in-unit-t…
Browse files Browse the repository at this point in the history
…ests

System prompt UI widget unit test
  • Loading branch information
tisnik authored Jan 20, 2025
2 parents 25e6fb6 + 923d20e commit e875ae8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/ui/test_gradio_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import requests

from ols import config
from ols.src.ui.gradio_ui import GradioUI
from ols.utils.logging_configurator import LoggingConfig, configure_logging

Expand All @@ -27,6 +28,29 @@ def test_gradio_ui_constructor():
assert ui.ols_url == url
assert ui.conversation_id == conversation_id

assert len(ui.ui.additional_inputs) == 3
assert ui.ui.additional_inputs[0].label == "Use history"
assert ui.ui.additional_inputs[1].label == "Provider"
assert ui.ui.additional_inputs[2].label == "Model"


def test_gradio_ui_prompt_override_enabled():
"""Test if GradioUI is able to create text area for system prompt."""
url = "locahost:8080"
conversation_id = "01234567-89ab-cdef-0123-456789abcdef"
config.dev_config.enable_system_prompt_override = True

ui = GradioUI(ols_url=url, conversation_id=conversation_id)
assert ui is not None
assert ui.ols_url == url
assert ui.conversation_id == conversation_id

assert len(ui.ui.additional_inputs) == 4
assert ui.ui.additional_inputs[0].label == "Use history"
assert ui.ui.additional_inputs[1].label == "Provider"
assert ui.ui.additional_inputs[2].label == "Model"
assert ui.ui.additional_inputs[3].label == "System prompt"


def test_chat_ui_handler_ok_response(caplog):
"""Test the UI handler for proper REST API response."""
Expand Down

0 comments on commit e875ae8

Please sign in to comment.