File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
tests/integration_tests/chat_models Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ def _default_params(self) -> Dict[str, Any]:
43
43
base_params = {
44
44
"temperature" : self .temperature ,
45
45
"max_output_tokens" : self .max_output_tokens ,
46
- "top_k" : self .top_p ,
47
- "top_p" : self .top_k ,
46
+ "top_k" : self .top_k ,
47
+ "top_p" : self .top_p ,
48
48
}
49
49
return {** base_params }
50
50
Original file line number Diff line number Diff line change 7
7
Your end-user credentials would be used to make the calls (make sure you've run
8
8
`gcloud auth login` first).
9
9
"""
10
+ from unittest .mock import Mock , patch
11
+
10
12
import pytest
11
13
12
14
from langchain .chat_models import ChatVertexAI
@@ -86,3 +88,31 @@ def test_vertexai_single_call_failes_no_message() -> None:
86
88
str (exc_info .value )
87
89
== "You should provide at least one message to start the chat!"
88
90
)
91
+
92
+
93
+ def test_vertexai_args_passed () -> None :
94
+ response_text = "Goodbye"
95
+ user_prompt = "Hello"
96
+ prompt_params = {
97
+ "max_output_tokens" : 1 ,
98
+ "temperature" : 10000.0 ,
99
+ "top_k" : 10 ,
100
+ "top_p" : 0.5 ,
101
+ }
102
+
103
+ # Mock the library to ensure the args are passed correctly
104
+ with patch (
105
+ "vertexai.language_models._language_models.ChatSession.send_message"
106
+ ) as send_message :
107
+ mock_response = Mock (text = response_text )
108
+ send_message .return_value = mock_response
109
+
110
+ model = ChatVertexAI (** prompt_params )
111
+ message = HumanMessage (content = user_prompt )
112
+ response = model ([message ])
113
+
114
+ assert response .content == response_text
115
+ send_message .assert_called_once_with (
116
+ user_prompt ,
117
+ ** prompt_params ,
118
+ )
You can’t perform that action at this time.
0 commit comments