If a request fails, the curl error message is inserted into the comint buffer. This error message is then sent as context to chatGPT in subsequent requests. See log below. Should there be a way to skip curl errors from being sent?
// Request
curl https://api.openai.com/v1/chat/completions --fail --no-progress-meter -m 30 -H Content-Type: application/json -H Authorization: Bearer <redacted> -d {"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"Can you show an example display-buffer-alist? (elisp)"},{"role":"system","content":"Sure, here's an example `display-buffer-alist`:\n\n```\n(setq display-buffer-alist\n '((\"\\*Help\\*\" display-buffer-same-window)\n (\"\\\\*magit.*popup\\\\*\" display-buffer-below-selected)\n (\"\\\\*compilation\\\\*\" display-buffer-same-window)\n (\"\\\\*Customize.*\\\\*\" display-buffer-same-window)\n (\".*\" display-buffer-same-window)))\n```\n\nThis alist specifies how to display different kinds of buffers:\n\n- Buffers named \"\\*Help\\*\" are displayed in the same window they were opened in.\n- Buffers whose names match the regexp \"\\\\*magit.*popup\\\\*\" (e.g., \\*magit-commit-popup\\*) are displayed below the selected window.\n- Buffers named \"\\*compilation\\*\" are displayed in the same window they were opened in.\n- Buffers whose names match the regexp \"\\\\*Customize.*\\\\*\" (e.g., \\*Customize Group: magit\\*) are displayed in the same window they were opened in.\n- Any other buffer is displayed in the same window it was opened in.\n\nNote that the order of the entries in the alist matters—the first matching entry determines how the buffer is displayed."},{"role":"user","content":"Show an example of action-alist usage to set a frames height with display-buffer-alist"},{"role":"system","content":"Here's an example of using `action-alist` to set the height of a frame when displaying a buffer:\n\n```\n(defun set-frame-height (frame height)\n \"Sets the height of FRAME to HEIGHT.\"\n (set-frame-parameter frame 'height height))\n\n(setq display-buffer-alist\n '((\"\\\\*Org Agenda\\\\*\" display-buffer-pop-up-frame\n (set-frame-height . 30))))\n```\n\nIn this example, we have an `action-alist` specified for buffers whose names match the regexp \"\\\\*Org Agenda\\\\*\". When such a buffer is displayed, we use `display-buffer-pop-up-frame` to display it in a separate frame. Additionally, we specify an action to be performed after displaying the buffer—namely, to call the `set-frame-height` function with arguments `frame` (the frame that the buffer was displayed in) and `30` (the height we want to set the frame to).\n\nNote that `action-alist` actions are performed after the buffer is displayed, so we can use them to modify properties of the window/frame that the buffer was displayed in. In this example, we use `set-frame-height` to modify the height of the frame that the buffer is displayed in."},{"role":"user","content":"Is there no built-in way to do that?"}]}
// Response (active)
curl: (28) Operation timed out after 30001 milliseconds with 0 bytes received
// Request
curl https://api.openai.com/v1/chat/completions --fail --no-progress-meter -m 30 -H Content-Type: application/json -H Authorization: Bearer <redacted> -d {"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"Can you show an example display-buffer-alist? (elisp)"},{"role":"system","content":"Sure, here's an example `display-buffer-alist`:\n\n```\n(setq display-buffer-alist\n '((\"\\*Help\\*\" display-buffer-same-window)\n (\"\\\\*magit.*popup\\\\*\" display-buffer-below-selected)\n (\"\\\\*compilation\\\\*\" display-buffer-same-window)\n (\"\\\\*Customize.*\\\\*\" display-buffer-same-window)\n (\".*\" display-buffer-same-window)))\n```\n\nThis alist specifies how to display different kinds of buffers:\n\n- Buffers named \"\\*Help\\*\" are displayed in the same window they were opened in.\n- Buffers whose names match the regexp \"\\\\*magit.*popup\\\\*\" (e.g., \\*magit-commit-popup\\*) are displayed below the selected window.\n- Buffers named \"\\*compilation\\*\" are displayed in the same window they were opened in.\n- Buffers whose names match the regexp \"\\\\*Customize.*\\\\*\" (e.g., \\*Customize Group: magit\\*) are displayed in the same window they were opened in.\n- Any other buffer is displayed in the same window it was opened in.\n\nNote that the order of the entries in the alist matters—the first matching entry determines how the buffer is displayed."},{"role":"user","content":"Show an example of action-alist usage to set a frames height with display-buffer-alist"},{"role":"system","content":"Here's an example of using `action-alist` to set the height of a frame when displaying a buffer:\n\n```\n(defun set-frame-height (frame height)\n \"Sets the height of FRAME to HEIGHT.\"\n (set-frame-parameter frame 'height height))\n\n(setq display-buffer-alist\n '((\"\\\\*Org Agenda\\\\*\" display-buffer-pop-up-frame\n (set-frame-height . 30))))\n```\n\nIn this example, we have an `action-alist` specified for buffers whose names match the regexp \"\\\\*Org Agenda\\\\*\". When such a buffer is displayed, we use `display-buffer-pop-up-frame` to display it in a separate frame. Additionally, we specify an action to be performed after displaying the buffer—namely, to call the `set-frame-height` function with arguments `frame` (the frame that the buffer was displayed in) and `30` (the height we want to set the frame to).\n\nNote that `action-alist` actions are performed after the buffer is displayed, so we can use them to modify properties of the window/frame that the buffer was displayed in. In this example, we use `set-frame-height` to modify the height of the frame that the buffer is displayed in."},{"role":"user","content":"Is there no built-in way to do that?"},{"role":"system","content":"curl: (28) Operation timed out after 30001 milliseconds with 0 bytes received"},{"role":"user","content":"Are you still there?"}]}
// Response (active)
{
"id": "chatcmpl-6xEvSXvaI0hym5bgbsGwUYa3NweTh",
"object": "chat.completion",
"created": 1679576746,
"model": "gpt-3.5-turbo-0301",
"usage": {
"prompt_tokens": 599,
"completion_tokens": 108,
"total_tokens": 707
},
"choices": [
{
"message": {
"role": "assistant",
"content": "Yes, sorry about that. To answer your question, there is a built-in way to set the height of the frame when displaying a buffer using `display-buffer-alist`: \n\n```\n(setq display-buffer-alist\n '((\"\\\\*Org Agenda\\\\*\" display-buffer-pop-up-frame\n (height . 30))))\n```\n\nIn this example, we specify the `height` parameter in the `display-buffer-alist` entry for the \"\\*Org Agenda\\*\" buffer. This sets the height of the new frame to 30 lines."
},
"finish_reason": "stop",
"index": 0
}
]
}
If a request fails, the curl error message is inserted into the comint buffer. This error message is then sent as context to chatGPT in subsequent requests. See log below. Should there be a way to skip curl errors from being sent?