Skip to content

A LaunchBar Action to interact with ChatGPT.

Notifications You must be signed in to change notification settings

quinncomendant/ChipiChat.lbaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 

History

58 Commits
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

ChipiChat: LaunchBaršŸ„‚ChatGPT

A LaunchBar action to interact with the ChatGPT API. Responses are received directly in LaunchBar and can be browsed, opened, previewed with Quick Look, inserted, or sent to another action. Conversation history is preserved for context. Responses are cached on disk. Understands keyword modifiers and commands. ChatGPT system messages are configurable via personas. Requires an OpenAI API key.

Demo

Usage

Open ChipiChat in LaunchBar, hit the spacebar, enter a command or message, then hit return to send it to ChatGPT.

The input will be taken from the clipboard if no text is entered into LaunchBar. This enables a powerful workflow to quickly pass text through ChatGPT.

As an example, hereā€™s how you can send text on the clipboard to ChatGPT using the rewrite persona, and immediately insert the response into the frontmost document (watch a screencast of this):

  1. Select and copy text in a document.
  2. Invoke ChipiChat.
  3. Type rewrite and hit ā‡§ ā†µ.
  4. ChatGPTā€™s response replaces the selected text.

Response manipulation

  • āŒ˜ ā†µ (command + return) Open the response in your text editor.
  • ā‡§ ā†µ (shift + return) Insert the response at the current cursor position.
  • āŒƒ ā†µ (control + return) Quick Look the response.
  • āŒ˜ Y Quick Look the response.
  • āŒ˜ C Copy the response to the clipboard.
  • ā†µ (return) Open the response in your text editor (reconfigurable using the default_action config option).
  • ā†’ (right-arrow) Browse the response as a list (ideal for acting on specific lines of text).
  • ā‡„ (tab) Send the text to other LaunchBar targets, e.g., send the output to a friend by passing it to the Compose Message action.

Keyword modifiers

Prefix your message with one-or-more modifiers for enhanced functionality:

  • (persona name): Use a predefined or custom persona.
  • N.N: Adjust response randomness by using the specified temperature value, e.g., ā€œ1.0 why is the sky blue?ā€.
  • 4: Use the GPT-4 model (requires GPT-4 API access).
  • copy: Automatically copy the response to the clipboard.
  • image: Generate an image with DALLĀ·E and return the image URL.
  • new: Start a new conversation with no history.
  • transient: Exclude conversation history for this message.

You can combine modifiers, e.g., ā€œcode copy 4 js uuid functionā€ sends ā€œjs uuid functionā€ to GPT-4 API with the code persona and copies the response. All modifiers must go at the beginning of the message.

Commands

Manage conversation history, settings, and personas by sending commands to ChipiChat:

  • help: Display a short user guide.
  • history: Display recent conversation history.
  • export: Save conversation history to a file in ~/Downloads/.
  • clear: Erase all conversation history (otherwise, conversations are saved for the duration defined by the history_expiration_days config option).
  • cache: Open the cache directory in the Finder.
  • config list: Show current configuration settings.
  • config reset: Reset all configuration options to default.
  • config set OPTION VALUE: Set the configuration OPTION to VALUE, e.g., config set default_action alert.
  • persona list: View a summary of personas.
  • persona export: Save all personas and their prompts to a file in ~/Downloads/.
  • persona delete NAME: Delete a persona.
  • persona reset: Reset personas to default. This will erase any custom personas you added.
  • persona set default SYSTEM_MESSAGE: Change the default personaā€™s system message.
  • persona set NAME SYSTEM_MESSAGE: Add or modify a persona.
  • redo: Regenerate the response using a random temperature between 0ā€“1.
  • version: Display ChipiChat version and check if a new version is available.

Installation

Prerequisite: you must have LaunchBar installed.

Get an OpenAI API key

Before you can use ChatGPT, you must get an OpenAI API key:

  1. Create an OpenAI account.
  2. Add a credit card in Account ā†’ Billing ā†’ Payment methods.
  3. Create a new secret API key.

Install ChipiChat

  1. Download ChipiChat.lbaction.zip from releases.
  2. Unzip it, and double-click the resulting ChipiChat.lbaction file to install (or manually move it into ~/Library/Application Support/LaunchBar/Actions/).
  3. (optional) If you get this warning message, run the following command in Terminal.app to remove the Gatekeeper quarantine attribute:
xattr -d com.apple.quarantine ~/Library/Application\ Support/LaunchBar/Actions/ChipiChat.lbaction
  1. Open LaunchBar and type cc to invoke ChipiChat.
  2. Hit the spacebar, type config set api_key YOURAPIKEYHERE, and hit return to save your API key in LaunchBar:

config set api_key yourkeyhere

(Alternatively, you can use export OPENAI_API_KEY="ā€¦" in your shell profile.)

Now youā€™re ready to use ChipiChat!

Usage example

Invoke ChipiChat, hit the spacebar, then type a message and hit return:

Example Message

After a couple seconds, you receive the response:

Response

Thatā€™s a bit hard to read because not all the response text is visible, but if you press the right-arrow key, you can view it as a list:

Response As List

Or, you can view it in Quick Look (press the left-arrow key to go back, then press āŒ˜ Y or āŒƒ ā†µ):

Response As Quick Look

ChipiChat has many features and myriad customizable options. Practice all the commands listed in usage and adjust the configuration options until ChipiChat works exactly how you want it to.

Updating

  1. Run the version command to check for new versions.
  2. Download the new ChipiChat.lbaction.zip file from releases, unzip it, and double-click it to install.
  3. Read the change log on the release page, which may have special instructions such as a requirement to run config reset after updating.

Personas

Use a persona to set the overall behavior of the assistant. Create your own or use one of the predefined personas (changelog, code, commit, complete, condense, expand, fix, list, reply, rewrite, safe, summarize, write). A default persona is used if no persona is specified when you send a message.

Manage personas with these commands:

  • persona list: View a summary of personas.
  • persona export: Save all personas and their prompts to a file in ~/Downloads/.
  • persona delete NAME: Delete a persona.
  • persona reset: Reset personas to default. This will erase any custom personas you added.
  • persona set default SYSTEM_MESSAGE: Change the default personaā€™s system message.
  • persona set NAME SYSTEM_MESSAGE: Add or modify a persona.

The SYSTEM_MESSAGE is the system message that is included with the request to ChatGPT that influences the behavior of the assistant.

As an example, to create a persona named ā€œPierreā€ which translates user messages to French:

persona set pierre Translate the user message to French

To use a persona, add the personaā€™s NAME to the beginning of your message. So, to use the Pierre persona, just write ā€œpierre retirement in france must be amazingā€ and the assistant will respond, ā€œLa retraite en France doit ĆŖtre incroyable.ā€ The persona can be combined with other keyword modifiers, e.g., ā€œcopy list mexican zombie filmsā€ to use the list persona and copy the results to the clipboard automatically.

Configuration

The following options can be changed using the config set OPTION VALUE command. For example, to change the default_action:

config set default_action quicklook

To view currently-set values, send the config list command.

To reset all configuration options to default, send the config reset command.

Options

  • api_key: Your OpenAI API key (default: empty or imported from $OPENAI_API_KEY).
  • cache_enable: If you prefer to have a fresh response for every message, set this to false (default: true).
  • cache_expiration_minutes: How long before cached responses expire. This is useful to avoid loading a cached response for the same question in a different context, e.g., the message ā€œplease continueā€ might match a cached response from an earlier reply (default: 15). If a message loads a cached response unexpectedly, you can reduce the cache expiration, clear the history, or just send the query again with extra characters that make it unique.
  • cache_min_words: Minimum words in input text required before response is cached. Short phrases are less unique, and are more likely to load cached responses from a different context (default: 3).
  • default_action: The action to run when hitting return after receiving a response (options: open, insert, quicklook, alert, copy, largetype; default: open).
  • default_action_auto: Set this to true to run the default_action automatically without having to hit return after receiving a response (options: true, false; default: false).
  • hide: Set this to true to hide LaunchBar while waiting for a response from ChatGPT (options: true, false; default: false).
  • history_expiration_days: How long before old messages are removed from the conversation history (default: 7).
  • filename_extension: The extension of cached files changes how they open in a text editor and Quick Look (options: txt, md, markdown; default: txt). If you have a Quick Look extension that supports Markdown (e.g., Peek), change this to md for syntax highlighting.
  • max_history_minutes: Maximum age of conversation history to include in requests for context (default: 480).
  • max_history_tokens: Maximum amount of conversation history to include in requests for context (default: 1000).
  • max_response_tokens: Maximum amount of tokens to return in the response (default: Infinity).
  • model: Which OpenAI model to use (default: gpt-3.5-turbo).
  • temperature: What sampling temperature to use, between 0.0 and 2.0 (default: 0.1).
  • timeout: How many seconds to wait for a response from the API (default: 30; using GPT-4 adds timeout + 120 seconds).

Default actions

Use the default_action and default_action_auto options to customize your preferred interface for receiving responses.

  • open: Open the response in the default text editor. Hide LaunchBar.
  • insert: Paste the contents of the response into the cursor position. Hide LaunchBar.
  • quicklook: Open the response in Quick Look. LaunchBar remains open, so you can easily close the Quick Look (Esc key) and do something else with the response.
  • alert: Open the response in a LaunchBar alert. Hit ā€œReplyā€ to keep the conversation going (the cursor will return to the input field, ready to send the next message).
  • copy: Copy the contents of the response on the clipboard. Hide LaunchBar.
  • largetype: Open the response in a LaunchBarā€™s large type display. Only useful for short responses.

Set default_action_auto to true to automatically open the default action without needing to press return after receiving a response.

Tips

If you use a Quick Look plugin that formats markdown with syntax highlighting (such as Peek), these settings will open every response in Quick Look:

config set filename_extension md
config set default_action quicklook
config set default_action_auto true

The best settings to carry on a conversation is to use LaunchBar alerts, which has a Reply button:

config set default_action alert
config set default_action_auto true

The open and insert actions are best for generating content, such as generating blog posts or emails.

The open and quicklook actions are best for generating code. Also press the right-arrow on a response to view it as a list of items, then copyā€“paste just the few lines that you need.

Remember, you can override the default action behavior by holding command, shift, or control when you hit return to open, insert, or Quick Look the response.

Press the right-arrow to view a response as a list with icons representing parts of Markdown content (šŸž for code, āš«ļø for ordered list, ā–¶ļø for unordered list, and šŸ’¬ for all other text).

If youā€™re annoyed that LaunchBar remains on the screen while waiting for a response, turn on hiding: config set hide true.

Alternatives

Support

Contact me on Twitter, the Fediverse, or create a GitHub issue.

Do you find this free software useful? Say thanks with a coffee!


ChipiChat icon