[WIP] Add possibility to register functions in a type-safe manner #787
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.
Goal: The goal of this PR is to extend the existing function registration methods to also accept types of beans. The advantage would be that this is type-safe. A type-safe interface improves intelli-sense and refactoring
Things to Do:
Discussion Points for this PR:
Should there be multiple factory methods for the ChatClient.Builder? So far I've overloaded the existing factory method and provided a
SimpleNameResolver
for use in existing callsGeneral Design Question:
At a higher level I am also wondering about how to register functions in general. The existing model make heavy use of annotations and conventions (e.g. a function must be a
java.util.Function
). This clearly works, however issues non-obvious issues (e.g. missing@Description
annotation) are discovered at runtime. Personally I feel that this is not a great developer experience, especially for people new to the usingspring-ai
. My preference would be to surface this kind of errors as quickly as possible. A way to address this could be to provide an interface that has to be implemented by beans that should be available as functions for the LLM