gptel icon indicating copy to clipboard operation
gptel copied to clipboard

Binding RET to gptel-return-dwim, don't need press C-c to send prompt.

Open manateelazycat opened this issue 1 year ago • 4 comments

Hi, I've added a gptel-return-dwim function today, which will detect every time you press the RET key, execute gptel-send if it starts with #, otherwise call the RET function

In this way, we can just press RET for normal use, and we don't need to press the C-c prefix button every time

manateelazycat avatar Sep 27 '24 05:09 manateelazycat

@KarimAziev Can you help to review this patch? Thanks

manateelazycat avatar Sep 28 '24 15:09 manateelazycat

Hi @manateelazycat, I believe you might have meant to mention karthink, the owner and maintainer of this repository. I just contributed once but I'm not actively maintaining the project.

KarimAziev avatar Sep 30 '24 17:09 KarimAziev

I think there's some misunderstanding here about how prompts work in gptel. gptel does not have a "prompt line" or require a prompt prefix character like ###. Everything up to the cursor position is part of the prompt. Consider this example:

#### In this quote:

"To be more explicit, we do not know why the standard model is based on the
gauge group SU(3)xSU(2)xU(1)/Z_6, and not some other gauge group. Even given
that gauge group, the standard model does not specify why it uses such a long,
apparently arbitrary, list of particles to represent that group. The standard
model does not explain why its quarks and leptons are organized into three
generations. It does not explain why SU(2) weak isospin acts only on left-handed
states."

What kind of product are they talking about by "x"?  Is it the cartesian product
or the tensor product?

*Response*: The "x" in the quote refers to the *direct product* of groups. It is
not the Cartesian product or the tensor product.

The direct product of groups is a way to combine multiple groups into a larger
group. In the context of the standard model, the direct product \(SU(3)\times
SU(2) \times U(1)\) represents the combination of three different gauge groups:

- *SU(3)*: The gauge group of strong interactions, responsible for the forces
  that bind quarks together.
- *SU(2)*: The gauge group of weak interactions, responsible for processes like
  beta decay.
- *U(1)*: The gauge group of electromagnetic interactions, responsible for the
  forces between charged particles.

The quotient group \(\frac{SU(3)\times SU(2) \times U(1)}{Z_6}\) is a slight
modification of the direct product, where \(Z_6\) is a cyclic group of
order 6. This modification is necessary to ensure that the standard model
correctly describes the interactions of particles.

In this exchange, everything up to the last line I typed: or the tensor product? is sent as part of the user prompt.

The default prompt and response prefix strings in chat sessions (here #### and *Response*: respectively) are just visual aids for the user, they don't imply any parsing logic.

karthink avatar Oct 03 '24 18:10 karthink

I know that ### doesn't necessarily start with a prompt, it may be the content of the AI response.

However, it is more frequently used to send requests to the AI or enter RET in normal content, so we should improve the ease of use of these high-frequency keys, and if there is really text starting with ### in the content, we should encourage the user to use other keys to solve the problem at this time.

manateelazycat avatar Oct 04 '24 02:10 manateelazycat

@manateelazycat I don't want to overload a basic key like RET in Markdown or Org mode files so I'm closing this PR. This kind of customization is best left to the user's personal preferences.

karthink avatar Mar 13 '25 04:03 karthink