Skip to content

rajp152k/fabric-gpt.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

fabric-gpt.el

License Contributions Welcome

fabric-gpt.el: Integrate Fabric Prompts with Gptel

Seamlessly access and utilize the community-driven prompts from the Fabric project directly within Emacs using Gptel. Enhance your LLM interactions with a rich library of curated system prompts.

Features

  • **Sparse Checkout:** Efficiently fetches only the necessary `patterns` subdirectory from the Fabric repository using Git sparse checkout.
  • **Pattern Filtering:** Automatically identifies and lists only patterns that have a valid `system.md` file.
  • **Completing Read Integration:** Select patterns easily using Emacs’ built-in completion (like Vertico, Ivy, Helm, etc.).
  • **Seamless Gptel Integration:** Applies the selected Fabric system prompt to your current Gptel conversation without modifying your default `gptel-system-message`.
  • **Easy Syncing:** Provides a command to quickly update your local pattern cache from the Fabric upstream.

Installation

While installation via MELPA is the recommended method (once available), you can also install manually.

Doom Emacs

In your packages.el, after your gptel fetch:

(package! fabric-gpt.el
  :recipe (:host github :repo "/rajp152k/fabric-gpt.el"))

In your config.el, after your gptel config:

(use-package! fabric-gpt.el
  :after gptel
  :config
  ;; Set the root directory where fabric patterns will be cached.
  ;; This should be outside your Emacs configuration directory.
  (setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example path
  (fabric-gpt.el-sync-patterns))

Manual Installation

  1. Clone the repository:
    git clone https://github.com/rajp152k/fabric-gpt.el.git ~/.emacs.d/site-lisp/fabric-gpt.el
        

    (Replace `~/.emacs.d/site-lisp/` with your preferred location)

  2. Add the directory to your `load-path` and require the package in your Emacs config:
    (add-to-list 'load-path "~/.emacs.d/site-lisp/fabric-gpt.el") ;; Adjust path
    (require 'fabric-gpt.el)
    
    ;; Configure the root directory for patterns
    (setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example path
    
    ;; Sync patterns on startup (optional, but recommended)
    (fabric-gpt.el-sync-patterns)
        

Usage

Using a Fabric Pattern (`fabric-gpt.el-send`)

This is the primary command for applying a Fabric pattern to your Gptel interaction.

  1. Invoke `M-x fabric-gpt.el-send` (or your bound keybinding).
  2. A completing read prompt will appear, listing available Fabric patterns.
  3. Select the desired pattern.
  4. The system prompt from the selected pattern’s `system.md` file will be temporarily applied to the next Gptel request sent from the current buffer.
  5. Your existing buffer content (before the cursor) will be sent as the user message, preceded by the selected system prompt.

I would recommend you bind (fabric-gpt.el-send) to something handy, I use “leader i g f f” as it is mnemonically aligned with what gptel exposes via “leader i g [hsm]”.

path/to/your/usage_screenshot_or_gif.gif ;; <– Add a path to a screenshot or GIF here

Syncing Patterns (`fabric-gpt.el-sync-patterns`)

This command fetches the latest patterns from the upstream Fabric repository.

Invoke `M-x fabric-gpt.el-sync-patterns` (or your bound keybinding). This will:

  1. Clone or update the Fabric repository in the directory specified by `fabric-gpt.el-root`.
  2. Perform a sparse checkout to only retrieve the `patterns` subdirectory.
  3. Populate the list of available patterns by checking for `system.md` files.

I bind (fabric-gpt.el-sync-patterns) to “leader i g f s” to fetch any new patterns from the fabric upstream.

These are pulled into your <fabric-gpt.el-root>/fabric directory.

Configuration

  • fabric-gpt.el-root: **Required.** A string specifying the root directory where the Fabric repository will be cloned and patterns cached. Make sure this directory exists and is writable by Emacs.
    (setq fabric-gpt.el-root "~/.emacs.d/.cache/fabric-gpt/") ;; Example
        

Community

Contributing

Suggestions, ideas, bug reports, and PRs are welcome! I’m still refining this package and appreciate any feedback.

License

This project is licensed under the GNU General Public License Version 3.

About

Fabric Prompts for emacs gpt.el

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published