-
Notifications
You must be signed in to change notification settings - Fork 39
Auto select functions for Chat Completion #132
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
Comments
This could be a helper class that would store the list of all the tools and would expose a method to feed the List<Tool> functions(Object toolChoice) {
...
} The parameter would have the same value being used for the The logic of the new method
@the-gigi, Am I missing something? NOTE: By the way, it is supposed that as a user of this library, you will be responsible to analyze the context in every chat cycle and determine the correct value for the |
This covers all the cases. I assume the helper class is going to be used internally. right? The user doesn't have to call it before populating a ChatRequest. |
I think that the // create a list of all your functions
List<FunctionDef> functionList = new ArrayList<>()
functionList.add(functionDefinition1)
functionList.add(functionDefinition2)
...
functionList.add(functionDefinitionN)
// create the function executor and populate it
var functionExecutor = new FunctionExecutor(functionList)
// create the list of messages
List<ChatMessage> messages = new ArrayList<>()
while (continueConversation) {
myToolChoice = ... // calculate it based off the current conversation context
// create the chat request as usual passing on parameters, including tools and toolChoice
chatRequest = ChatRequest.builder()
.tools(functionExecutor.getToolFunctions(myToolChoice)) // getToolFunctions already exists ...
.toolChoice(myToolChoice) // ... and it will be overloaded
.messages(messages)
.otherParameters(...)
.build()
// call chat completions service
var chatStream = openAI.chatCompletions().createStream(chatRequest).join()
// process response and add chat messages
...
} |
@the-gigi any concern with the proposal? |
@sashirestela No concern. It keeps the API the same, so users are not impacted and the FunctionExecutor encapsulates the logic of pruning the tools according to the user's tool choice. I think it's a clean design. |
This is an extra feature whose benefit was identified in:
openai/openai-openapi#259 (comment)
The text was updated successfully, but these errors were encountered: