Add SpringAIFunctions annotation to turn Functions into ToolFunctionCallbacks #16
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Hey! First contribution, so open for suggestions!
The main reason I found myself drawn to this project is in my quest for making a super discord bot, being able to parse natural language to function calls in spring would be pretty cool. So while kind of basic I think it gives something to build on or get the conversation started on supporting functions. I saw #7 and figured I could take a crack at it.
I liked the idea of it being annotation based so I added
@SpringAIFunctionas a generic annotation. I don't personally know the extent that azure supports functions but I figured it might be useful to live there as spring AI supports different APIs.There might be a way to not need to specify the class directly in the annotation, but my reflection skills are not there 😆
This annotation is used with
OpenAiFunctionManagerto look for anyFunctionannotated with the new annotation, and return them to whoever needs them as aFunctionExecutor. I wasn't sure how to make sure that my functions as beans are created before the manager, but if thats not guaranteed, I can always make the executor a singleton after the first timegetFunctionExecutor()is run.After things get a little bit finalized I can add some documentation around this.
I also updated
open-ai-client.versionto0.16.0for function support