gptel icon indicating copy to clipboard operation
gptel copied to clipboard

gptel-org-branching-context requires Org 9.7 (unreleased)

Open localauthor opened this issue 9 months ago • 5 comments

Hi Karthik, first, thanks for gptel. It is truly wonderful.

It seems that gptel-org-branching-context depends on the function org-element-lineage-map, which is not included in the current release of Org (9.6.27), at least as far as I can tell.

It seems that the file containing that function, org-element-ast.el, is in org's main branch, but 9.6 is not built with it. I do not know why it is excluded, at least in my case.

Might the branching-context feature be adapted (without too much trouble) for those of us on just this side of org's bleeding edge? Thanks for considering it, in any case.

localauthor avatar Apr 25 '24 09:04 localauthor

Flying by the seat of my pants here -- I bundled org-element-lineage-map with gptel, to be evaluated at compile time if it's not natively available. Please let me know if it works, or if there are transitive dependencies that are also missing.

karthink avatar Apr 25 '24 21:04 karthink

Looks like there are quite a few other functions that would also need to be bundled:

org-element-parent org-element-begin org-element-type org-element-type-p org-element-secondary-p

Not sure if bundling all these is something you would want to do.

In the meantime, I've just defined all these in my init file and gptel-org-branching-context works great.

karthink @.***> writes:

Flying by the seat of my pants here -- I bundled org-element-lineage-map with gptel, to be evaluated at compile time if it's not natively available. Please let me know if it works, or if there are transitive dependencies that are also missing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

localauthor avatar Apr 26 '24 06:04 localauthor

Oof, my fix was shortsighted then, as I expected.

I'm not sure what I can do here. I can throw a warning when setting gptel-org-branching-context if the org version is not high enough, and disable it. But this warning will only fire if setting the variable using setopt or the customization menu, which I doubt most users are using.

karthink avatar Apr 28 '24 03:04 karthink

Or maybe instead of a warning when setting the variable, a warning when calling gptel-send in a context when a user might expect it to work, but they don’t have the right org version. Or even simpler (and what I would do) just a note about the org version requirement in the doc string. Dont think it’s worth much more effort than that, honestly. 

 From: karthink @.>Sent: Sunday, April 28, 2024 06:22To: karthink/gptel @.>Cc: Grant Rosson @.>; Author @.>Subject: Re: [karthink/gptel] gptel-org-branching-context requires Org 9.7 (unreleased) (Issue #294)  Oof, my fix was shortsighted then, as I expected. I'm not sure what I can do here. I can throw a warning when setting gptel-org-branching-context if the org version is not high enough, and disable it. But this warning will only fire if setting the variable using setopt or the customization menu, which I doubt most users are using.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

localauthor avatar Apr 28 '24 09:04 localauthor

Perhaps someone would find it useful, if only temporarily, if you mentioned this package, which provides a similar feature (as a light wrapper around gptel) using released versions of org.

ultronozm avatar May 14 '24 19:05 ultronozm

Thank you @ultronozm.

@localauthor I added a warning when gptel-org-branching-context is set if it can't find org-element-lineage-map. I don't check for the availability of org-element-parent and the rest, but I think anyone updating from an older Org version for this feature will update to the tip of the Org main branch so this should suffice.

karthink avatar May 17 '24 20:05 karthink

I'm running emacs.29.4 + latest spacemacs develop + org.9.7.8 + gptel-20240718.2048 and at doing an actual request send to openai server I'm getting an error:

gptel-org--create-prompt: Symbol's function definition is void: gptel-org--element-lineage-map

The problem gets fixed after enclosing eval-when-compile is commented out

I experience the problem since very beginning of my journey with gptel, ie since emacs 29.3 org.9.6.15 and gptelfrom about 2 months ago

should I open new issue?

vibrys avatar Jul 24 '24 12:07 vibrys

@vibrys Thanks for letting me know. I've tried to fix it in the latest commit.

karthink avatar Jul 24 '24 20:07 karthink

@karthink, thank you for prompt response. Although your newest fix hasn't been propagated yet, I've taken it manually to my copy of a gptel-org package to see if it has chance to help and it looks like the fix is doing the job.

thank you! also thank you for gptel!

vibrys avatar Jul 24 '24 20:07 vibrys