3737import  org .springframework .util .ReflectionUtils ;
3838
3939import  static  org .assertj .core .api .Assertions .assertThat ;
40- import  static  org .assertj .core .api .Assertions .assertThatCode ;
4140import  static  org .assertj .core .api .AssertionsForClassTypes .assertThatThrownBy ;
4241
4342@ SpringBootTest (classes  = OpenAiTestConfiguration .class )
@@ -166,12 +165,12 @@ void methodGetWeatherToolContext() {
166165	}
167166
168167	@ Test 
169- 	void  methodGetWeatherNonStaticButWithToolContext () {
168+ 	void  methodGetWeatherToolContextButMissingContextArgument () {
170169
171170		TestFunctionClass  targetObject  = new  TestFunctionClass ();
172171
173- 		var  toolMethod  = ReflectionUtils .findMethod (TestFunctionClass .class , "getWeatherNonStatic " , String .class ,
174- 				Unit .class );
172+ 		var  toolMethod  = ReflectionUtils .findMethod (TestFunctionClass .class , "getWeatherWithContext " , String .class ,
173+ 				Unit .class ,  ToolContext . class );
175174
176175		// @formatter:off 
177176		assertThatThrownBy (() -> ChatClient .create (this .chatModel ).prompt ()
@@ -183,37 +182,13 @@ void methodGetWeatherNonStaticButWithToolContext() {
183182					.toolMethod (toolMethod )
184183					.toolObject (targetObject )
185184					.build ())
186- 				.toolContext (Map .of ("tool-context" , "value" ))
187185				.call ()
188186				.content ())
189187				.isInstanceOf (IllegalArgumentException .class )
190188				.hasMessage ("ToolContext is required by the method as an argument" );
191189		// @formatter:on 
192190	}
193191
194- 	@ Test 
195- 	void  methodGetWeatherToolContextButWithoutToolContext () {
196- 
197- 		TestFunctionClass  targetObject  = new  TestFunctionClass ();
198- 
199- 		var  toolMethod  = ReflectionUtils .findMethod (TestFunctionClass .class , "getWeatherWithContext" , String .class ,
200- 				Unit .class , ToolContext .class );
201- 
202- 		// @formatter:off 
203- 		assertThatCode (() ->ChatClient .create (this .chatModel ).prompt ()
204- 				.user ("What's the weather like in San Francisco, Tokyo, and Paris?  Use Celsius." )
205- 				.toolCallbacks (MethodToolCallback .builder ()
206- 						.toolDefinition (ToolDefinitions .builder (toolMethod )
207- 								.description ("Get the weather in location" )
208- 								.build ())
209- 						.toolMethod (toolMethod )
210- 						.toolObject (targetObject )
211- 						.build ())
212- 				.call ()
213- 				.content ()).doesNotThrowAnyException ();
214- 		// @formatter:on 
215- 	}
216- 
217192	@ Test 
218193	void  methodNoParameters () {
219194
0 commit comments