This is a bit of a long shot, but maybe somebody has a tip.
I am using apex_web_service
to call the OpenAI chat endpoint (on-premise, APEX 23.2.2, Oracle 19.3, AL32UTF8 character set).
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
apex_web_service.g_request_headers(2).name := 'Authorization';
apex_web_service.g_request_headers(2).value := 'Bearer '||l_key;
l_body := '{"messages": [{"role": "user", "content": "my prompt"}], "model": "gpt-4o-mini", "temperature": 0.7}';
l_resp_body := apex_web_service.make_rest_request(
p_url => 'https://api.openai.com/v1/chat/completions',
p_http_method => 'POST',
p_wallet_path => l_wallet_path,
p_body => l_body
);
This works, but there is a weird problem with the return value (about half the time): there is an unexpected or strange character at one particular point in the JSON response.
Part of the returned JSON should be:
"message": {
"role": "assistant",
"content": "Concrete block",
"refusal": null
}
But I regularly get something like this:
"cont5nt": "Concrete block",
"cont(nt": "Concrete block",
"contnt": "Concrete block",
It's always “content” that gets f'd up, which is precisely where I have to look for the chat response 😒
I have no idea how I can find the root cause for this problem. I doubt that it is OpenAI that sends this response.