Skip to content

gptel-org: put hardcoded gptel-org-property-names into variable #575

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hrehfeld
Copy link

@hrehfeld hrehfeld commented Jan 20, 2025

so other (potentially external) code can reference them.

e.g. I have org property inheritance disabled but want it enabled for gptel props:

  (cl-loop
   for prop in '("GPTEL_SYSTEM" "GPTEL_BACKEND" "GPTEL_MODEL"
            "GPTEL_TEMPERATURE" "GPTEL_MAX_TOKENS"
            "GPTEL_NUM_MESSAGES_TO_SEND")
   do
   (add-to-list 'org-use-property-inheritance prop))

becomes

  (cl-loop
   for prop in gptel-org-property-names
   do
   (add-to-list 'org-use-property-inheritance prop))

GPTEL_BOUNDS is purposely not included, because it seems like only used file globally.

@hrehfeld hrehfeld force-pushed the gptel-org-property-names branch 3 times, most recently from 3c5ce04 to c2ab967 Compare January 20, 2025 14:50
@karthink
Copy link
Owner

@hrehfeld thanks for the PR. While I'm okay with placing these in a variable, you can achieve the effect you want more easily via

(setq org-use-property-inheritance "^GPTEL_")

Any reason you don't want to use this?

  1. Could you make this defvar a defconst?
  2. Do you think the name gptel-org-properties might be better? If Org mode already has a convention for one of these (-properties vs -property-names for lists of properties) we can stick to it.

As an aside, not making these properties inheritable by default is intentional, see my comment about this in #141.

@hrehfeld hrehfeld force-pushed the gptel-org-property-names branch from c2ab967 to 74e2f3b Compare January 25, 2025 19:14
@hrehfeld
Copy link
Author

Fixed defconst. Also improved documentation, gave my use case as an example.

@hrehfeld
Copy link
Author

@hrehfeld thanks for the PR. While I'm okay with placing these in a variable, you can achieve the effect you want more easily via

(setq org-use-property-inheritance "^GPTEL_")

Any reason you don't want to use this?

1. Could you make this `defvar` a `defconst`?

2. Do you think the name `gptel-org-properties` might be better?  If Org mode already has a convention for one of these (`-properties` vs `-property-names` for lists of properties) we can stick to it.

As an aside, not making these properties inheritable by default is intentional, see my comment about this in #141.

Well, unless you're claiming the whole GPTEL_ property namespace ;-) it just feels less robust. And I figure my PR wouldn't cause you more work, as you're listing the properties anyways.

@hrehfeld
Copy link
Author

hrehfeld commented Jan 25, 2025

But wait. The code where list was hardcoded before is actually a pcase-let. So one CAN'T easily put new property names into my constant without also changing that code. (pcase-let doc: a mismatch may signal an error or may go undetected, binding variables to arbitrary values, such as nil.).

Which I did, I added GPTEL_TOPIC -- which doesn't make any sense, as TOPIC should always be inherited.

So we'd actually need another defconst just for that destructure, or hardcode it anyways and just ADD the constant. Or just give up on this?

Maybe the constant should be named something like gptel-org-property-names-selectively-inherited? 🫣

@karthink
Copy link
Owner

@hrehfeld You're right, this function combines property names with separate logic for handling each corresponding property value. So adding or removing topics from the defconst won't be enough, you'll also have to provide the logic. I'm not sure it's worth writing and managing separate functions for handling each property at this point.

Well, unless you're claiming the whole GPTEL_ property namespace

I'm not seeing the problem with this, at least as far as inheritance is concerned?

@karthink
Copy link
Owner

karthink commented Feb 6, 2025

So we'd actually need another defconst just for that destructure, or hardcode it anyways and just ADD the constant. Or just give up on this?

I'm leaning towards closing this PR. Before I do that, I'd like to take a step back and reconsider the need for this. What do you want to be able to do with gptel-org-property-names exactly?

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

Successfully merging this pull request may close these issues.

2 participants