1515import java .util .List ;
1616import java .util .function .Function ;
1717import org .springframework .ai .chat .prompt .Prompt ;
18+ import org .springframework .ai .model .function .DefaultFunctionCallbackBuilder ;
1819import org .springframework .ai .model .function .FunctionCallback ;
19- import org .springframework .ai .model .function .FunctionCallbackContext ;
20- import org .springframework .ai .model .function .FunctionCallbackWrapper ;
20+ import org .springframework .ai .model .function .FunctionCallbackResolver ;
2121
2222public class FunctionExampleMain {
2323
@@ -37,7 +37,7 @@ public AddResponse apply(AddRequest addRequest) {
3737 }
3838 }
3939
40- static class SimpleFunctionCallbackContext extends FunctionCallbackContext {
40+ static class SimpleFunctionCallbackContext implements FunctionCallbackResolver {
4141
4242 private final FunctionCallback functionCallback ;
4343
@@ -46,8 +46,7 @@ static class SimpleFunctionCallbackContext extends FunctionCallbackContext {
4646 }
4747
4848 @ Override
49- public FunctionCallback getFunctionCallback (String beanName ,
50- String defaultDescription ) {
49+ public FunctionCallback resolve (String name ) {
5150 return functionCallback ;
5251 }
5352 }
@@ -80,9 +79,8 @@ String runFunction() {
8079 .build ();
8180 var tool = new AddFunctionTool ();
8281 var context = new SimpleFunctionCallbackContext (
83- FunctionCallbackWrapper .builder (tool )
84- .withName ("add" )
85- .withDescription ("add two numbers" )
82+ new DefaultFunctionCallbackBuilder ().function ("add" , tool )
83+ .description ("add two numbers" )
8684 .build ());
8785 var model = new DashscopeChatModel (new DashscopeApi (), context );
8886 var response = model .call (new Prompt ("add 100 to 200" , options ));
0 commit comments