@@ -135,12 +135,7 @@ def subtract(a: int, b: int) -> int:
135
135
if os .path .exists (server_script_path ):
136
136
os .remove (server_script_path )
137
137
138
- @pytest .mark .skipif (
139
- (not os .environ .get ("OPENAI_API_KEY" ) and not os .environ .get ("BRAVE_API_KEY" ))
140
- or (sys .platform == "win32" )
141
- or (sys .platform == "darwin" ),
142
- reason = "OPENAI_API_KEY or BRAVE_API_KEY not set, or running on Windows or macOS" ,
143
- )
138
+ @pytest .mark .skip ("Brave is temporarily not returning results" )
144
139
def test_mcp_brave_search (self , mcp_tool_cleanup ):
145
140
"""Test using an MCPTool in a pipeline with OpenAI."""
146
141
@@ -165,14 +160,16 @@ def test_mcp_brave_search(self, mcp_tool_cleanup):
165
160
166
161
# Create pipeline with OpenAIChatGenerator and ToolInvoker
167
162
pipeline = Pipeline ()
168
- pipeline .add_component ("llm" , OpenAIChatGenerator (model = "gpt-4o -mini" , tools = [tool ]))
163
+ pipeline .add_component ("llm" , OpenAIChatGenerator (model = "gpt-4.1 -mini" , tools = [tool ]))
169
164
pipeline .add_component ("tool_invoker" , ToolInvoker (tools = [tool ]))
170
165
171
166
# Connect components
172
167
pipeline .connect ("llm.replies" , "tool_invoker.messages" )
173
168
174
169
# Create a message that should trigger tool use
175
- message = ChatMessage .from_user (text = "Use brave_web_search to search for the latest German elections news" )
170
+ message = ChatMessage .from_user (
171
+ text = "Use brave_web_search to search for the latest news about the stock market, use the `query` parameter"
172
+ )
176
173
177
174
result = pipeline .run ({"llm" : {"messages" : [message ]}})
178
175
@@ -181,10 +178,10 @@ def test_mcp_brave_search(self, mcp_tool_cleanup):
181
178
182
179
tool_message = tool_messages [0 ]
183
180
assert tool_message .is_from (ChatRole .TOOL )
184
- assert any (term in tool_message . tool_call_result . result for term in [ "Bundestag" , "election" ]), (
185
- "Result should contain information about German elections"
186
- f" \n \n Result: { tool_message . tool_call_result . result } "
187
- )
181
+ assert any (
182
+ term in tool_message . tool_call_result . result
183
+ for term in [ "equity" , "market" , "stock" , "price" , "NASDAQ" , "S&P 500" ]
184
+ ), f"Result should contain information about the stock market \n \n Result: { tool_message . tool_call_result . result } "
188
185
189
186
@pytest .mark .skipif (not os .environ .get ("OPENAI_API_KEY" ), reason = "OPENAI_API_KEY not set" )
190
187
def test_mcp_tool_in_pipeline_with_multiple_tools (self , mcp_tool_cleanup ):
@@ -211,7 +208,7 @@ def test_mcp_tool_in_pipeline_with_multiple_tools(self, mcp_tool_cleanup):
211
208
212
209
# Create pipeline with OpenAIChatGenerator and ToolInvoker
213
210
pipeline = Pipeline ()
214
- pipeline .add_component ("llm" , OpenAIChatGenerator (model = "gpt-4o -mini" , tools = [echo_tool , time_tool ]))
211
+ pipeline .add_component ("llm" , OpenAIChatGenerator (model = "gpt-4.1 -mini" , tools = [echo_tool , time_tool ]))
215
212
pipeline .add_component ("tool_invoker" , ToolInvoker (tools = [echo_tool , time_tool ]))
216
213
217
214
pipeline .connect ("llm.replies" , "tool_invoker.messages" )
0 commit comments