Bug description ChatCompletionRequest property toolChoice is always a string however for specifying particular function to use it should be parsed to a JSON object instead of a string. tool_choice generated using OpenAiApi.ChatCompletionRequest.ToolChoiceBuilder.FUNCTION("functionName") (parsed to JSON) looks like this: } ], "tool_choice" : "{\"function\":{\"name\":\"functionName\"},\"type\":\"function\"}" }
Environment Java 17, spring-ai-openai-spring-boot-starter, model GPT-4
Steps to reproduce * configure OpenAiApi object * use OpenAiApi#chatCompletionEntity(new OpenAiApi.ChatCompletionRequest([messages], "gpt-4", [tools], OpenAiApi.ChatCompletionRequest.ToolChoiceBuilder.FUNCTION("functionName") * OpenAI Completions API returns HTTP 400: "error": { "message": "'$.tool_choice' is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference.", "type": "invalid_request_error", "param": null, "code": null }
Expected behavior OpenAiApi.ChatCompletionRequest.ToolChoiceBuilder.FUNCTION("functionName") should be returning an Object and toolChoice should be an Object (String / Object) as well.
Comment From: tzolov
@DC2Software thanks for catching this! I will try to reproduce it shortly.
Comment From: tzolov
@DC2Software please give it a try. It seems that when you set an explicit function the parallel function calling is not working anymore.