File size: 765 Bytes
8029d8e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pytest
from streamlit_app import ask, clean_chat_log

def test_ask():
    question = "What's your name?"
    chat_log = ""
    model = 'text-davinci-003'
    temp = 0.9

    answer, log = ask(question, chat_log, model, temp)

    assert isinstance(answer, str)
    assert isinstance(log, str)

def test_clean_chat_log():
    # Test case 1
    input_chat_log = ['hello', 'world\n', 'how', 'are', 'you\n']
    expected_output = '  how are you '
    assert clean_chat_log(input_chat_log) == expected_output

    # Test case 2
    input_chat_log = ['\n', 'this', 'is', 'a', 'new', 'line\n', '\n']
    expected_output = '  this is a new line   '
    output = clean_chat_log(input_chat_log)
    assert output == expected_output
    assert isinstance(output, str)