Summary

Here’s a demonstration of how to use ilambda for emacs.

This is all you need to do to use ilambda :).

Thin-client demo

Firstly, start the pen server in the background. You will need to follow setup instructions for pen.el

Initial pen server setup

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
git clone "https://github.com/semiosis/pen.el"
git clone "https://github.com/semiosis/prompts"

mkdir -p ~/.pen

# Put in your keys, or do not, it's up to you!
echo "sk-<openai key here>" > ~/.pen/openai_api_key       # https://openai.com/
echo "<ai21 key here>" > ~/.pen/ai21_api_key              # https://www.ai21.com/
echo "<hf key here>" > ~/.pen/hf_api_key                  # https://huggingface.co/
echo "<nlpcloud key here>" > ~/.pen/nlpcloud_api_key      # https://nlpcloud.io/
echo "<alephalpha key here>" > ~/.pen/alephalpha_api_key  # https://aleph-alpha.de/
echo "<cohere key here>" > ~/.pen/cohere_api_key          # https://cohere.ai/

# Add the scripts to the PATH
echo export PATH="$(realpath .)/pen.el/scripts:\$PATH" >> ~/.profile

# Add this to prevent C-s from freezing the terminal
echo "stty stop undef 2>/dev/null; stty start undef 2>/dev/null" | tee -a ~/.zshrc >> ~/.bashrc

# Source your .profile
. ~/.profile

# Run pen in the background, and ensure everything is pulled and up-to-date
pen -nw

Force the engine to the key you have, if you don’t have the OpenAI key

If you have an OpenAI key, then most prompts/features/applications will simply work without further setup. If you don’t have an OpenAI key, but have another key such as AI21 then you can force all prompts to use the key you have.

I will demonstrate forcing Pen.el to use the Cohere engine for everything. This is useful if you only have a Cohere key.

1
2
# Run this on your host machine
pen config

Ensure this is enabled:

1
(setq pen-prompt-force-engine-disabled t)

And this is set:

1
(setq pen-force-engine "Cohere")

Now to showcase ilambda

1
2
# Start a vanilla emacs
emacs -nw -Q
1
2
3
;; Load the libaries inside the vanilla emacs
(load "/home/shane/source/git/semiosis/pen.el/src/ilambda.el")
(load "/home/shane/source/git/semiosis/pen.el/src/pen-client.el")
1
2
3
4
5
6
7
8
(require 'pen-client)
(require 'ilambda)

(setq iฮป-thin t)

(idefun thing-to-hex-color (thing))

(message (thing-to-hex-color "watermelon"))
1
(message (apply (idefun translate-to-pirate (phrase) "reword the phrase to sound like a pirate") '("Let's go, my friend")))

As you can see, that all works well.

Demo