Skip to content
/ aibo Public

aibo is an Emacs package that leverages OpenAI's chat API to bring ChatGPT into Emacs

License

Notifications You must be signed in to change notification settings

dmed256/aibo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aibo

aibo melpa badge aibo-server Python version badge

aibo is an Emacs package that leverages OpenAI's chat API to bring ChatGPT into Emacs

asciicast

⚠️ Disclaimer

  • 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

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_MODULE to your custom Python module (e.g. aibo.packages).
  • The aibo server automatically runs on emacs which includes hot-reloading (Default: localhost:5000 on the *Aibo server* buffer)
  • Inject images from clipboard using the \im shorthand (⚠️ requires gpt-4-vision access). Press [RET] on conversation [Image:<id>] links to open in a local browser.

Installation

To use aibo, both the Python server and the Elisp package need to be installed. Here's how:

  1. Clone the aibo repository:
git clone https://github.com/dmed256/aibo.git
  1. Install Python dependencies:

2.1. Install using pip

pip install aibo-server

2.2. Install using the cloned git repo

cd aibo/python
pip install -e .[dev]
  1. Update your Emacs configuration file (~/.emacs or ~/.emacs.d/init.el):
(add-to-list 'load-path "/path/to/aibo")
(require 'aibo)
  1. Make sure your OPENAI_API_KEY environment variable is set

  2. Restart or eval the Elisp code snippet.

Optional keybindings and Ivy buffer configurations are detailed below.

Keybindings and Configurations

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")

Usage

Starting a new Conversation

Start a new conversation using aibo:create-conversation (M-/.)

Homepage

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

Conversation

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 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

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>]
\im The clipboard image content if the clipboard has an image
\sc Similar to \im but takes a screenshot of your monitor

Customization

For Elisp customizations, refer to aibo-custom.el.

For Python environment customizations, refer to constants.py.

Deploy

ˢᶦⁿᶜᵉ ᶦ ᶠᵒʳᵍᵉᵗ

After updating the pyproject.toml version:

python -m build
python -m twine upload dist/*

About

aibo is an Emacs package that leverages OpenAI's chat API to bring ChatGPT into Emacs

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published