karthink / gptel

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

Evaluate elisp/shell in prompts #328

Open osheari1 opened 1 week ago

osheari1 commented 1 week ago

Currently prompts can only be static. Adding syntax that would evaluate an elisp statement / shell commands would allow dynamic prompting.

Potential Use Cases

Data extraction from local machine

Gives the ability to load data from a shell command, local file, ect, into the prompt without copy paste.

# prompt
Format the contents of a directory as a table of contents in markdown: (shell-command-to-string "ls") 

or

# prompt
Format the contents of a directory as a table of contents in markdown: $(ls)

Prompt organization

(technically the same thing as the previous) Would allow organization of long complex prompts

# Directory structure
# TODO-1.org
# TODO-2.org
# TODO-3.org

# Prompt
You are a careful programmer. Complete all TODO instructions. First $(cat TODO-1.org), then $(cat TODO-2.org), then $(cat TODO-3.org)

Example from Alternative

shell_gpt

>>> sgpt "format the contents of a directory as a markdown table of contents: $(ls)"
- [README.md](README.md)
- [some-file.md](some-file.md)
- [documents](documents)
karthink commented 1 week ago

Thanks, this is a neat idea. I'll look into adding something like this.