karthink / gptel

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

Evaluate elisp/shell in prompts #328

Open osheari1 opened 5 months ago

osheari1 commented 5 months 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 5 months ago

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

nfedyashev commented 3 months ago

Super excited about this Another probable use case: elisp function that reads database schema and the injects it into the prompt, "given the following DB schema \n... write SQL migration that does X"

karthink commented 2 months ago

This is still on the docket -- I just need to fix a few other things in gptel before I can get to this.