@@ -756,6 +756,16 @@ def test_chat(self):
756
756
output_text = "Ned likes watching movies." ,
757
757
),
758
758
],
759
+ message_history = [
760
+ preview_language_models .ChatMessage (
761
+ author = preview_language_models .ChatSession .USER_AUTHOR ,
762
+ content = "Question 1?" ,
763
+ ),
764
+ preview_language_models .ChatMessage (
765
+ author = preview_language_models .ChatSession .MODEL_AUTHOR ,
766
+ content = "Answer 1." ,
767
+ ),
768
+ ],
759
769
temperature = 0.0 ,
760
770
)
761
771
@@ -773,11 +783,11 @@ def test_chat(self):
773
783
]
774
784
response = chat .send_message (message_text1 )
775
785
assert response .text == expected_response1
776
- assert len (chat .message_history ) == 2
777
- assert chat .message_history [0 ].author == chat .USER_AUTHOR
778
- assert chat .message_history [0 ].content == message_text1
779
- assert chat .message_history [1 ].author == chat .MODEL_AUTHOR
780
- assert chat .message_history [1 ].content == expected_response1
786
+ assert len (chat .message_history ) == 4
787
+ assert chat .message_history [2 ].author == chat .USER_AUTHOR
788
+ assert chat .message_history [2 ].content == message_text1
789
+ assert chat .message_history [3 ].author == chat .MODEL_AUTHOR
790
+ assert chat .message_history [3 ].content == expected_response1
781
791
782
792
gca_predict_response2 = gca_prediction_service .PredictResponse ()
783
793
gca_predict_response2 .predictions .append (_TEST_CHAT_GENERATION_PREDICTION2 )
@@ -793,11 +803,11 @@ def test_chat(self):
793
803
]
794
804
response = chat .send_message (message_text2 , temperature = 0.1 )
795
805
assert response .text == expected_response2
796
- assert len (chat .message_history ) == 4
797
- assert chat .message_history [2 ].author == chat .USER_AUTHOR
798
- assert chat .message_history [2 ].content == message_text2
799
- assert chat .message_history [3 ].author == chat .MODEL_AUTHOR
800
- assert chat .message_history [3 ].content == expected_response2
806
+ assert len (chat .message_history ) == 6
807
+ assert chat .message_history [4 ].author == chat .USER_AUTHOR
808
+ assert chat .message_history [4 ].content == message_text2
809
+ assert chat .message_history [5 ].author == chat .MODEL_AUTHOR
810
+ assert chat .message_history [5 ].content == expected_response2
801
811
802
812
# Validating the parameters
803
813
chat_temperature = 0.1
0 commit comments