Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Awkward behavior due to openai-completion-select-insert calling (forward-paragraph) #20

Open
rommeswi opened this issue Apr 17, 2023 · 6 comments

Comments

@rommeswi
Copy link

If you use openai-completion-select-insert on a selected paragraph, then the response will be inserted after the following paragraph instead of directly after the paragraph.

This happens because openai-completion-select-insert calls (forward-paragraph) before insertion.
Of course it is equally awkward if after selecting only part of a paragraph and sending it to openai, the result appears in the middle of the paragraph, so just removing (forward-paragraph) would not be good.

I do not know an elegant solution to this issue. Perhaps it is possible to pass an optional argument to openai-completion-select-insert not to skip to the next paragraph? Similar issues may arise due to newline characters being added (in some use cases these might not be desirable). If one could pass optional arguments such as "prefix", "suffix" (which default to "\n") and "position" (which defaults to "(goto-char end) (forward-paragraph)"), then this would allow users to use for example advice-add to fine-tune the placement of the response.

@jcs090218
Copy link
Member

jcs090218 commented Apr 17, 2023

Yeah, you are correct. I've re-implemented it in 6a1d270, so it works better in most circumstances. Basically, it will always insert the output with newlines at the front and at the end. This way user can see the output better and know what to do later on (remove it? or merge it into the paragraph? etc). Can you try the latest version? Thanks!

@rommeswi
Copy link
Author

I tested the new version and found that if I submit a statement such as (1) "Define a Hamel basis in R^2.\n" or (2) "Define a Hamel basis in R^2.", the new version inserts the response to (1) before "^2" and to (2) after "^2" but before "."

@jcs090218
Copy link
Member

jcs090218 commented Apr 18, 2023

Can you paste a screenshot or steps to reproduce the issue? It's hard to imagine the error by reading the description. Thanks!

@rommeswi
Copy link
Author

Write "Define a Hamel basis in R^2." into the scratch buffer.
Mark the entire text above without any newline.
Call "openai-completion-select-insert" command.

Observed behavior:
Buffer changes to:
"Define a Hamel basis in R^2

A Hamel basis in R^2 is any set of two linearly independent vectors that span
the entire space. For example, a Hamel basis in R^2 can be chosen as {(1,0),
(0,1)}.

."

Notice the extra dot at the end of the text which is now missing from the end of the original text. The behavior becomes even stranger if one marks "Define a Hamel basis in R^2.\n".

@jcs090218
Copy link
Member

jcs090218 commented Apr 20, 2023

This is the result on my end:

Define a Hamel basis in R^2.

A Hamel basis for R^2 is an unordered set of two linearly independent vectors
{v1, v2} such that no vector in the set can be expressed as a linear combination
of the other vectors. For example, a Hamel basis in R^2 could be {v1 = (1,2), v2
= (3,4)}.

It seems fine to me. 🤔

@rommeswi
Copy link
Author

I wonder what the issue is. Must be something related to spacemacs I would guess. Somehow both the chatgpt and this package don't work well with each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants