File size: 1,096 Bytes
589bda1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557f6db
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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'"