Streaming generates wrong enum (function argument)

Hi,

When sending this request:

{
  "model": "gpt-4-turbo-preview",
  "messages": [
    {
      "role": "user",
      "content": "What is the weather in Boston?"
    }
  ],
  "stream": true,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "unit": {
              "type": "string",
              "enum": [
                "celsius",
                "fahrenheit"
              ]
            },
            "location": {
              "description": "The city and state, e.g. San Francisco, CA",
              "type": "string"
            }
          },
          "required": [
            "location"
          ]
        }
      }
    }
  ],
  "tool_choice": {
    "type": "function",
    "function": {
      "name": "get_current_weather"
    }
  }
}

I am getting these SSEs:

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“role”:“assistant”,“content”:null,“tool_calls”:[{“index”:0,“id”:“call_Q2CTSuzddw3bUF4CJfzAL7w3”,“type”:“function”,“function”:{“name”:“get_current_weather”,“arguments”:“”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“{"”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“location”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“":"”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“Boston”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“,”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:" MA"}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“","”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“unit”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“":"”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“f”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“elsius”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{“tool_calls”:[{“index”:0,“function”:{“arguments”:“"}”}}]},“logprobs”:null,“finish_reason”:null}]}

{“id”:“chatcmpl-94jYesfhSphhdeFXBapVgPcceXMnY”,“object”:“chat.completion.chunk”,“created”:1710915464,“model”:“gpt-4-0125-preview”,“system_fingerprint”:“fp_ace12ee232”,“choices”:[{“index”:0,“delta”:{},“logprobs”:null,“finish_reason”:“stop”}]}

As you can see, the generated value for “unit” is “felsius” :slight_smile: