Skip to content

[QUERY] [openai] Difference in response for tools call using java and python library to same model with same parameters #40040

Open
@sravanthi-tl

Description

@sravanthi-tl

Query/Question
I have a openai fn defined as tool which makes a function call cancel_booking with all required user details. We are using 2024-02-15-preview model which is deployed on azure. Keeping the tool definition same and model version same along with temperature ... we made calls using

  1. py script using openai sdk and
  2. azure-ai-openai.1.0.0-beta.8

On user_message: Hello this is Barry Spencer. Im personal assistant to the Smith's. Can you please cancel appointments of Will Smith and Jaden Smith.

  1. py script is returning 2 function calls .. cancel_booking(Will Smith), cancel_booking(Jaden Smith) consistently
  2. java sdk is returning only one call cancel_booking(Will Smith) even though all params seem to be the same

Am unable to figure out the difference between these 2 calls and why there is a difference in response.

Tool Definition

{
        "system": "You are a cancel bot helping people cancel their appointment. When a user asks for cancelling their booking, you should call cancel_booking function with appropriate parameters. If there are requests for multiple cancels make multiple function calls. Don't make assumptions about what values to use with functions. Ask for clarification if a user request is ambiguous. \n For example\n USER:I would like to cancel two appointments, one that is scheduled on 5th May at 10am on phone +18978191080 on my name Gary Shepard and another appointment for my wife (Noel Shepard) scheduled on 10th May on phone +1234567890.\nOutput: cancel_booking({{Gary Shepard, +18978191080, 5th May at 10am}}), cancel_booking({{Noel Shepard, +1234567890, 10th May}}) ",
        "tool_choice": "auto",
        "tools": [
            {
                "function": {
                    "description": "When a user asks for cancelling their booking, you should call cancel_booking function with appropriate parameters. If there are requests for multiple cancels make multiple function calls. Don't make assumptions about what values to use with functions. Ask for clarification if a user request is ambiguous.",
                    "name": "cancel_booking",
                    "parameters": {
                        "properties": {
                            "date_time_of_appointment": {
                                "description": "time and date  of the appointment that is being cancelled",
                                "type": "string"
                            },
                            "name": {
                                "description": "Name of user whose appointment is to be cancelled, maybe different from caller",
                                "type": "string"
                            },
                            "phone": {
                                "description": "comma separated phone number(s) of user whose appointment is to be cancelled ",
                                "type": "string"
                            }
                        },
                        "required": [
                            "name",
                            "phone"
                        ],
                        "type": "object"
                    }
                },
                "type": "function"
            }

java call

 ChatCompletions chatCompletions = client.getChatCompletions(this.deploymentOrModelId,
                            new ChatCompletionsOptions(chatMessages)
                                    .setTemperature(0.0)
                                    .setTools(toolDefinitionsList)
                                    .setToolChoice(BinaryData.fromObject("auto")));
                                    

log stmt of request sent to openai

May 05 21:02:22.514 [ForkJoinPool.commonPool-worker-9] INFO com.azure.ai.openai.implementation.OpenAIClientImpl$OpenAIClientService.getChatCompletionsSync - {"az.sdk.message":"HTTP response","statusCode":200,"url":"https://HOST.openai.azure.com/openai/deployments/gpt-35-turbo-0125/chat/completions?api-version=2024-02-15-preview","durationMs":1663}

java call response received

image

py side log of request made and response received

Screenshot 2024-05-05 at 9 20 33 PM

Metadata

Metadata

Assignees

Labels

OpenAIcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions