spring-ai
spring-ai copied to clipboard
[FeatureRequest] Avoid second roudtrip when call functions
Expected Behavior For some customers we do not have necessity to pass the function-result to LLMs again.
Eg: extract some information from a blob of text and save it in structured mode. That can be accomplished with a function call with in input the "data structure" but the output is not necessary, so we can avoid totally the "second call" to LLM.
Current Behavior Every function must return a value that is passed to LLM to produce a nice output.
Context As workaround we implement some function with "spying" capability (like tests) and use it to grab the "first call" data. And ignore completly the second call-result.
We try to add this feature in spring-ai I think that can be useful to others. Or at least anyone can decide.
@Grogdunn , are you referring to providing support for Function<SomeRequest, Void>? E.g. function with Void response?
If so shouldn't the implementation detect the Void response definition and handle it accordingly? rather than masking it via fake string response and additional property flags?
Ok! Good point
@tzolov Ok Done, if you use a Function<Input, Void> or a Consumer<Input> the second round-trip is skipped
EDIT: if more function are called (if model support it) even if only one called function returns a value the second roundtrip is done.