Share via

gpt 0613 streamed function_call response missing "arguments".

gimling 0 Reputation points
2023-07-25T16:24:23.59+00:00

I'm try to use the new function call ability with gpt-35-turbo and gpt-4.

When I use function call without stream, everything looks fine.

request

{
    "messages":[
        {
            "role":"user",
            "content":"Find beachfront hotels in San Diego for less than $300 a month with free breakfast."
        }
    ],
    "functions":[
        {
            "name":"search_hotels",
            "description":"Retrieves hotels from the search index based on the parameters provided",
            "parameters":{
                "type":"object",
                "properties":{
                    "location":{
                        "type":"string",
                        "description":"The location of the hotel (i.e. Seattle, WA)"
                    },
                    "max_price":{
                        "type":"number",
                        "description":"The maximum price for the hotel"
                    },
                    "features":{
                        "type":"string",
                        "description":"A comma separated list of features (i.e. beachfront, free wifi, etc.)"
                    }
                },
                "required":[
                    "location"
                ]
            }
        }
    ],
    "stream":true
}

response

{
    "id": "chatcmpl-7gExCICGZN9A6K6nzVCacyZD0GcH7",
    "object": "chat.completion",
    "created": 1690301614,
    "model": "gpt-35-turbo",
    "prompt_annotations": [
        {
            "prompt_index": 0,
            "content_filter_results": {}
        }
    ],
    "choices": [
        {
            "index": 0,
            "finish_reason": "function_call",
            "message": {
                "role": "assistant",
                "function_call": {
                    "name": "search_hotels",
                    "arguments": "{\n\"location\": \"San Diego\",\n\"max_price\": 300,\n\"features\": \"beachfront,free breakfast\"\n}"
                }
            },
            "content_filter_result": {
                "error": {
                    "code": "content_filter_error",
                    "message": "The contents are not filtered"
                }
            },
            "content_filter_results": {}
        }
    ],
    "usage": {
        "completion_tokens": 34,
        "prompt_tokens": 120,
        "total_tokens": 154
    }
}

But when I use the same messages, functions with stream is on, the function_call field “argument” in response is misssing .

{"id":"","object":"","created":0,"model":"","prompt_annotations":[{"prompt_index":0,"content_filter_results":{}}],"choices":[],"usage":null}

{"id":"chatcmpl-7gF43LHCgx0xqORaeUbula3PPq1Ff","object":"chat.completion.chunk","created":1690302039,"model":"gpt-35-turbo","choices":[{"index":0,"finish_reason":null,"delta":{"role":"assistant","function_call":{"name":"search_hotels"}},"content_filter_result":{"error":{"code":"content_filter_error","message":"The contents are not filtered"}},"content_filter_results":{}}],"usage":null}

Can't some one tell me why.

Community Center | Not monitored

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.