karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.21k stars 122 forks source link

Org support #8

Closed minad closed 1 year ago

minad commented 1 year ago

I saw that you consider adding this. What are the obstacles? Could you use some generic regexp-based machinery to support different file types? Maybe you also need some converter for the responses, which I suspect are in markdown?

karthink commented 1 year ago

@minad Hi!

I'm almost done with org support, I should be adding it in 30 minutes or so.

For the last couple of days I was trying to get ChatGPT to reply with org-formatted responses by using a prompt, but the results were inconsistent and non-reproducible. I guess this element of randomness is expected with LLMs.

So I wrote a basic converter for the responses instead. (Suggested markdown -> org solutions all seemed to involve pandoc, so I wrote a very basic parser in elisp.)


BTW the readme doesn't mention this yet, but you can use gptel in any buffer by selecting a region and calling gptel-send, the special buffer is not needed. You can then select a region that includes your prompt and its response and call gptel-send again to continue the conversation. (Responses are tracked using a text property.)

karthink commented 1 year ago

Org support added in 9db679dd.

You can enable it with

(setq gptel-default-mode 'org-mode
      gptel-prompt-string "*** ") ;<-- or anything you'd like

Alternatively, you can directly call gptel-send from an org-mode buffer (with a region of text selected) and it should work correctly.

minad commented 1 year ago

Great, I will try this now!

hab25 commented 5 months ago

@karthink

(Suggested markdown -> org solutions all seemed to involve pandoc, so I wrote a very basic parser in elisp.)

Why avoid pandoc? IMO reuse of a much more complete and robust implementation seems like too enormous of a benefit.