-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add support for passing a FunctionCallbackWrapper when registering functions via ChatClientRequestSpec #1303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Milestone
Comments
tzolov
added a commit
to tzolov/spring-ai
that referenced
this issue
Oct 4, 2024
This commit adds support for tool context in various chat options classes across different AI model implementations and enhances function calling capabilities. The tool context allows passing additional contextual information to function callbacks. - Add toolContext field to chat options classes - Update builder classes to support setting toolContext - Enhance FunctionCallback interface to support context-aware function calls - Update AbstractFunctionCallback to implement BiFunction instead of Function - Modify FunctionCallbackWrapper to support both Function and BiFunction and to use the new SchemaType location - Add support for BiFunction in TypeResolverHelper - Update ChatClient interface and DefaultChatClient implementation to support new function calling methods with Function, BiFunction and FunctionCallback arguments - Refactor AbstractToolCallSupport to pass tool context to function execution - Update all affected <Model>ChatOptions with tool context support - Simplify OpenAiChatClientMultipleFunctionCallsIT test - Add tests for function calling with tool context - Add new test cases for function callbacks with context in various integration tests - Modify existing tests to incorporate new context-aware function calling capabilities Resolves spring-projects#864, spring-projects#1303, spring-projects#991
markpollack
pushed a commit
that referenced
this issue
Oct 4, 2024
This commit adds support for tool context in various chat options classes across different AI model implementations and enhances function calling capabilities. The tool context allows passing additional contextual information to function callbacks. - Add toolContext field to chat options classes - Update builder classes to support setting toolContext - Enhance FunctionCallback interface to support context-aware function calls - Update AbstractFunctionCallback to implement BiFunction instead of Function - Modify FunctionCallbackWrapper to support both Function and BiFunction and to use the new SchemaType location - Add support for BiFunction in TypeResolverHelper - Update ChatClient interface and DefaultChatClient implementation to support new function calling methods with Function, BiFunction and FunctionCallback arguments - Refactor AbstractToolCallSupport to pass tool context to function execution - Update all affected <Model>ChatOptions with tool context support - Simplify OpenAiChatClientMultipleFunctionCallsIT test - Add tests for function calling with tool context - Add new test cases for function callbacks with context in various integration tests - Modify existing tests to incorporate new context-aware function calling capabilities - Add docs in in openai function calling Resolves #864, #1303, #991
@PedroAlvarado with 9c10a08 we extended the ChatClient API with ChatClientRequestSpec functions(FunctionCallback... functionCallbacks). |
@PedroAlvarado I'm closing this issue as resolved by 9c10a08 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
It'd be great to have greater control on the FunctionCallbackWrapper created when dynamically providing functions to the ChatClient.
Expected Behavior
Current Behavior
Currently, it is not possible to customize the FunctionCallbackWrapper created when using the methods below. For example, a custom ObjectMapper can not be set. This means that custom Jackson modules can not be registed such as the
com.fasterxml.jackson.module.kotlin.kotlinModule
.Context
The workaround at the moment is to register the FunctionCallbackWrapper using the ChatModel interface directly rather than the ChatClient interface. ChatOptions can be used as well via model specific implementation.
If this change makes sense, I can submit a PR.
The text was updated successfully, but these errors were encountered: