Skip to content

Commit

Permalink
fix prompting in org-ai-refactor-code
Browse files Browse the repository at this point in the history
  • Loading branch information
rksm committed Oct 20, 2024
1 parent c8977cf commit 5adfde1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.5.4] - 2024-10-20
### Changed
- fix prompting in `org-ai-refactor-code`

## [0.5.3] - 2024-10-20
### Changed
- fix progress reporter for non-streamed responses (fixes completion for o1 models)
Expand Down
3 changes: 2 additions & 1 deletion org-ai-openai.el
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ and the length in chars of the pre-change text replaced by that range."
(set-marker org-ai--url-buffer-last-position-marker (point)))
(error
(setq errored t)
(goto-char org-ai--url-buffer-last-position-marker)))))))))))))
(when org-ai--url-buffer-last-position-marker
(goto-char org-ai--url-buffer-last-position-marker))))))))))))))

(defun org-ai--stream-supported (service model)
"Check if the stream is supported by the service and model.
Expand Down
6 changes: 4 additions & 2 deletions org-ai-useful.el
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,17 @@ Will always return t if `org-ai-talk-confirm-speech-input' is nil."
(let ((output-buffer (or output-buffer (current-buffer)))
(start-pos-marker (point-marker)))
(let* ((sys-input (if sys-prompt (format "[SYS]: %s\n" sys-prompt)))
(input (format "%s\n[ME]: %s" sys-input prompt)))
(input (format "%s\n[ME]: %s" sys-input prompt))
(callback-called nil))
(with-current-buffer output-buffer
(setq org-ai-prompt--last-insertion-marker (point-marker)))
(org-ai-stream-request :messages (org-ai--collect-chat-messages input)
:model org-ai-default-chat-model
:callback (lambda (response)
(when (cl-some (lambda (ea) (eq 'stop (org-ai--response-type ea)))
(org-ai--insert-stream-response nil output-buffer response nil))
(when callback
(when (and callback (not callback-called))
(setq callback-called t)
(with-current-buffer
output-buffer (funcall callback))))))))))

Expand Down
2 changes: 1 addition & 1 deletion org-ai.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

;; Author: Robert Krahn <[email protected]>
;; URL: https://github.com/rksm/org-ai
;; Version: 0.5.3
;; Version: 0.5.4
;; Package-Requires: ((emacs "27.1") (websocket "1.15"))

;; This file is NOT part of GNU Emacs.
Expand Down

0 comments on commit 5adfde1

Please sign in to comment.