spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/index.html
Apache License 2.0
2.87k stars 716 forks source link

Enhance the expansibility of function call #1032

Open aRookieMan opened 2 months ago

aRookieMan commented 2 months ago

Spring AI is wonderful, but the form of calling function is not easy to extend. For example, I need to fetch the function calling state and result, send the function name or some thing for user to comfirm. In this case, I have to use my own Function interface, AbstractFunctionCall class and FunctionContext to define, invoke and manager the tool.

Can you make some progress to enhance the expansibility of function call ? plz...

tzolov commented 1 month ago

Thank you for the valuable feedback @aRookieMan !

We are considering two (likely exclusive) approaches to handle this:

  1. Optionally, return the message conversation history in the ChatResponse's metadata. E.g. the list of UserMessage, AssistantMessage and TooResponseMessage used in the function call interactions.
  2. After the recent refactoring of our function calling API we will make it possible to disable the automatic/internal function call loops but let the application perform those itself using the plain messages + some provided utility helpers. This is primary targetted for use cases and applications that want to deliberately shortcut some of the function calling steps (on their own risk).

What do you think. Would those help your use cases?