Spaces:
Build error
Build error
Download tests/test_chatbot.py from mlops-cs553-fall24/Local-Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/mlops-cs553-fall24/Local-Chatbot/resolve/main/tests/test_chatbot.py
- Command line
-
hf download hf://spaces/mlops-cs553-fall24/Local-Chatbot/tests/test_chatbot.py
-
curl -L -o test_chatbot.py https://huggingface.co/spaces/mlops-cs553-fall24/Local-Chatbot/resolve/main/tests/test_chatbot.py
1.1 kB
| import sys | |
| import os | |
| import pytest | |
| # Add the root directory of the project to the Python path | |
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | |
| from app import respond # Import your chatbot function | |
| def test_chatbot_response(): | |
| # Set up the input parameters for your chatbot | |
| message = "Hello" | |
| history = [] # Empty history for a new conversation | |
| system_message = "You are a friendly chatbot." | |
| max_tokens = 50 | |
| temperature = 0.7 | |
| top_p = 0.95 | |
| # Run the chatbot function | |
| response_generator = respond(message, history, system_message, max_tokens, temperature, top_p) | |
| # Collect the response from the generator | |
| response = next(response_generator) | |
| # Assertions to check that the response is not empty and seems reasonable | |
| assert response is not None, "Response should not be None" | |
| assert len(response) > 0, "Response should not be empty" | |
| assert len(response) > len(message), "Response should contain more than just the input" | |
| assert response.lower() != "hello", "Response should not be just 'Hello'" | |