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

Adding context files recursively from a directory #513

Open
hartikainen opened this issue Dec 21, 2024 · 4 comments
Open

Adding context files recursively from a directory #513

hartikainen opened this issue Dec 21, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@hartikainen
Copy link

Thanks for such a great and pleasant-to-use package!

I've had several occasions recently where I would've wanted to add the contents of a whole directory to the context of my model. I can do that manually but with more than a couple of files that becomes quite clumsy. It would be great if there was a function like gptel-add-directory or similar, which would allow files in the directory to be added, ideally recursively.

@hartikainen hartikainen added the enhancement New feature or request label Dec 21, 2024
@metachip
Copy link

Hi @hartikainen

This is a great idea.

It is related to a wider discussion about how to manage context beyond the "labour-intensive mechanism" that it offers now. Especially if one is used to using markdown or org mode as the source syntax for dialogue with the models. My view is that the management of context within gptel is an area that can be improved significantly with what are, conceptually at least, relatively minor changes.

The ability to add directories of files could be difficult to "keep simple". All nested subdirectories? Only files with specific extensions? Which ones? How should they be filtered? I'm sure there are ways to simplify this using metaphors like "dired", which can already be used in a way similar to this, But it is not automated in the way I think you are suggesting.

Have a look at the summary below and the related issues on this topic.

See what you think :)

1. Context Buffer Navigation (#459)

Suggestion:

  • Make context previews collapsible in the context buffer
  • Hide previews by default with TAB to reveal (similar to Magit)
  • Current preview chunks can be unwieldy when large

Status: Under consideration, but no specific implementation committed yet.

2. Multiple Context Sets (#475, #459)

Suggestion:

  • Support multiple named context buffers
  • Allow association between context sets and chat buffers
  • Use prefix arguments (C-u) to select context sets
  • Add widget to chat buffers showing active context

Karthink's Response (#475):

  • Concerned about user confusion and complexity
  • Prefers one-shot interactions without additional decisions
  • Raises questions about ambiguity in context assignment
  • Notes problems with maintaining internal registry
  • Suggests project-local contexts might be more intuitive

3. Links as Context (#481)

Suggestion:

  • Allow links in non-chat buffers
  • Support text file content via links
  • Remove standalone link requirement
  • Use :CONTEXT: drawer in org-mode to isolate LLM links
  • Support region targeting via link labels

Karthink's Response:

  • Supportive of using links for per-buffer context
  • Concerned about accidental inclusion of links
  • Prefers standalone links for clear intent
  • Willing to add text file support
  • Cautious about org-specific link types

4. Quick Context Management (#486)

Suggestion:

  • Add command to quickly delete all context
  • Provide way to temporarily ignore context

Status: Implemented

  • Context deletion added to transient menu (commit a844612)
  • Context ignoring available via -i option in transient menu
  • Can be toggled per-buffer using gptel-use-context

5. Multi-Modal Support

Status: Already Implemented

  • Image and media support added before 0.9.6
  • PDF support added for Claude 3.5 Sonnet
  • Can use gptel-add or links in Org/Markdown chat buffers

Current Direction

The discussion seems to be moving towards:

  1. Using links as the primary mechanism for context management (Media (and other) links. #481)
  2. Maintaining simplicity in the interface
  3. Avoiding complex context management systems
  4. Providing better ergonomics for existing features

Karthink appears most receptive to improvements that:

  • Maintain simplicity
  • Avoid additional user decisions
  • Provide clear intent
  • Work within existing Emacs paradigms

The most promising avenue appears to be the links-based approach (#481), which could provide a more transparent and user-friendly way to manage context while avoiding the complexity of multiple context sets.

[2024-12-22 Sun 10:03]

@karthink
Copy link
Owner

karthink commented Dec 23, 2024

@hartikainen see PR #438, which is almost ready to be merged.

Also, as a fallback for now you can mark all files in a directory wilth t in dired and add with gptel-add.

@karthink
Copy link
Owner

@metachip Thanks for the summary.

Hide previews by default with TAB to reveal (similar to Magit)

Current preview chunks can be unwieldy when large

Status: Under consideration, but no specific implementation committed yet.

This is trivial to add if we add magit-section as a dependency of gptel, I'm just hesitant to do that. gptel has one dependency (transient), and updates to it have cause gptel to break in minor ways multiple times this year.

  1. Links as Context (Media (and other) links. #481)

Yup, this is going to happen, I just have to merge the tool-use branch first.

@collinarnett
Copy link

It would be really cool if you could exclude based on a .gitignore if in a git project.

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

No branches or pull requests

4 participants