aibo is an Emacs package that leverages OpenAI's chat API to bring ChatGPT into Emacs
- I'm not familiar with elisp so there might be quirky code conventions used
- It's mainly a personal project but will try hard to keep things backwards compatible
- Since I do a lot of coding, I'll be adding more utilities to help with coding flows (e.g. LSP-integration and git repo integrations) so expect potentially random features
- Quickly create conversations from anywhere in emacs
- Persist all conversations and messages, enabling search on past conversations in a SQLite DB (Default:
~/.aibo/database.db) - Supports function-calling API through simple function decorators (package.py). To add custom packages, define
AIBO_CUSTOM_PACKAGES_MODULEto your custom Python module (e.g.aibo.packages). - The
aiboserver automatically runs on emacs which includes hot-reloading (Default:localhost:5000on the*Aibo server*buffer) - Inject images from clipboard using the
\imshorthand (⚠️ requires gpt-4-vision access). Press[RET]on conversation[Image:<id>]links to open in a local browser.
To use aibo, both the Python server and the Elisp package need to be installed. Here's how:
- Clone the
aiborepository:
git clone https://github.com/dmed256/aibo.git- Install Python dependencies:
2.1. Install using pip
pip install aibo-server2.2. Install using the cloned git repo
cd aibo/python
pip install -e .[dev]- Update your Emacs configuration file (
~/.emacsor~/.emacs.d/init.el):
(add-to-list 'load-path "/path/to/aibo")
(require 'aibo)-
Make sure your
OPENAI_API_KEYenvironment variable is set -
Restart or eval the Elisp code snippet.
Optional keybindings and Ivy buffer configurations are detailed below.
Here are my personal keybindings:
(global-set-key (kbd "C-M-h") 'aibo:homepage)
(global-set-key (kbd "C-M-s") 'aibo:message-search)
(global-set-key (kbd "C-M-y") 'aibo:rephrase-yank)
(global-set-key (kbd "M-/") 'aibo:create-conversation)Rephrase-yank inspired by this tweet.
Hide aibo buffers from Ivy by adding the following:
(add-to-list 'ivy-ignore-buffers "\\*Aibo")Start a new conversation using aibo:create-conversation (M-/.)
Access the conversation history using aibo:homepage (C-M-h), displaying conversation history and allowing soft-deletion of conversations and title editing.
Keybindings
| Keybind | Description | Command |
|---|---|---|
C-c C-x C-r |
Refresh homepage | aibo:refresh-homepage |
C-c p s |
Find conversations based on searching message contents | aibo:message-search |
Keybindings
| Keybind | Description | Command |
|---|---|---|
C-c C-x C-r |
Refresh the conversation | aibo:refresh-current-conversation |
C-c C-t |
Set the conversation title | aibo:set-current-conversation-title |
C-c f c |
Inject a file shorthand using counsel | aibo:insert-counsel-find-file-shorthand |
C-c f p |
Inject a file shorthand using projectile | aibo:insert-projectile-find-file-shorthand |
C-c i |
Inject an image shorthand using the current image in the clipboard | aibo:aibo:insert-image-shorthand |
C-c C-k |
Soft-delete the message at point | aibo:remove-message-at-point |
C-c C-x C-k |
Soft-delete all messages at point and after | aibo:remove-messages-after-point |
C-c C-c |
Regenerate last message | aibo:regenerate-current-conversation-last-assistant-message |
C-c C-x C-t |
Regenerate the conversation title based on the conversation content | aibo:generate-current-conversation-title |
M-RET |
If point is at the user input field, submit the message for an assistant response | aibo:submit-user-message |
Shorthands replace certain escaped text (e.g. \b) with other content dynamically before sampling the model
| Shorthand | Description |
|---|---|
\b |
The current buffer |
\r |
The current buffer's region |
\f |
Injects the given file with optional line/start/end args (\f[<filename>:<start>:<end>] |
\d |
Injects all the files in the directory or glob if passed (e.g. \d[<dir>] or \d[<dir>/**/*.py]) |
\i |
Injects the image by its UUID, easier to use the shorthand that creates the image and passes back the ID |
\im |
The clipboard image content if the clipboard has an image |
\sc |
Similar to \im but takes a screenshot of your monitor |
For Elisp customizations, refer to aibo-custom.el.
For Python environment customizations, refer to constants.py.
ˢᶦⁿᶜᵉ ᶦ ᶠᵒʳᵍᵉᵗ
After updating the pyproject.toml version:
python -m build
python -m twine upload dist/*