Closed doctorguile closed 7 months ago
attached 2023-03-15-preview api version response: note the choices array is always non empty
{
"id": "chatcmpl-8PbDDLVedJuLxct8SVxvSlp3UwTKn",
"object": "chat.completion.chunk",
"created": 1701111935,
"model": "gpt-35-turbo-16k",
"choices": [
{
"index": 0,
"finish_reason": null,
"delta": {
"role": "assistant"
}
}
]
}
{
"id": "chatcmpl-8PbDDLVedJuLxct8SVxvSlp3UwTKn",
"object": "chat.completion.chunk",
"created": 1701111935,
"model": "gpt-35-turbo-16k",
"choices": [
{
"index": 0,
"finish_reason": null,
"delta": {
"content": "This"
}
}
]
}
...
{
"id": "chatcmpl-8PbDDLVedJuLxct8SVxvSlp3UwTKn",
"object": "chat.completion.chunk",
"created": 1701111935,
"model": "gpt-35-turbo-16k",
"choices": [
{
"index": 0,
"finish_reason": null,
"delta": {
"content": "."
}
}
]
}
{
"id": "chatcmpl-8PbDDLVedJuLxct8SVxvSlp3UwTKn",
"object": "chat.completion.chunk",
"created": 1701111935,
"model": "gpt-35-turbo-16k",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"delta": {}
}
]
}
data: [DONE]
I have a patch for this fix
org-ai-openai.el
@@ -277,7 +277,7 @@ the response into."
;; insert text
(if-let* ((choices (or (alist-get 'choices response)
(plist-get response 'choices)))
- (choice (aref choices 0))
+ (choice (and (arrayp choices) (> (length choices) 0) (aref choices 0)))
(delta (plist-get choice 'delta)))
(cond
((plist-get delta 'role)
Will clean up the PR, rebase to latest commit and send PR your way (to support azure openai)
Thanks
created PR to support azure open-ai along with fixes for the above issue
Thank you very much!
Hi
I have a patch for Azure OpenAI here,
https://github.com/doctorguile/org-ai/commit/e6ddc16889a7eb4575d404f026caced38c6fde17
but I haven't submitted the PR yet because it seems like org-ai cannot handle newer api response json format from openai
api version 2023-07-01-preview response
Note the first response, the array
"choices": []
is emptyThis breaks org-ai's parsing.