• Stars
    star
    293
  • Rank 141,381 (Top 3 %)
  • Language
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎩 An Alfred 5 Workflow for using OpenAI Chat API to interact with GPT-3.5/GPT-4 πŸ€–πŸ’¬ It also allows image generation πŸ–ΌοΈ, image understanding πŸ‘€, speech-to-text conversion 🎀, and text-to-speech synthesis πŸ”ˆ

OpenAI Text-Completion Workflow for Alfred

Alfred 5 Workflow for using OpenAI GPT-3.5 and GPT-4 with Text Completion/Chat API. It also allows image generation using the DALL-E API.

Downloads

Current version: 1.10.3

Download Workflow

Change Log

  • 1.10.2: Enhance Prompt supports both gpt-4 and gpt-3.5-turbo.
  • 1.10.0: Enhance Prompt option for image generation mode added
  • 1.9.1: 1024x1024 image generation issue fixed
  • 1.9.0: Image generation using DALLΒ·E API supported
  • 1.8.2: New models (gpt-3.5-turbo-0613, gpt-3.5-turbo-16k-0613, gpt-4-0613) supported
  • 1.8.1: Added option to change base URL of the OpenAI API
  • 1.8.0: Custom CSS feature added
  • 1.7.0: Improved UI
  • 1.6.9: GPT-4 models (e.g., gpt-4) supported
  • 1.6.7: Fixed an error that occurred for some users
  • 1.6.6: Debug mode added that outputs error messages when problems occur
  • 1.6.5: Automatic detection of Pandoc installation
  • 1.6.4: Supress "Please Wait" message feature
  • 1.6.3: OpenAI Textbox feature updated
  • 1.6.0: GPT-3.5-turbo model is set to the default
  • 1.6.0: ChatGPT API support
  • 1.6.0: HTML output option (using Pandoc) is enabled by default
  • 1.6.0: check-for-update command removed (in preparation for Alfred Gallery inclusion)

Complete Change Log

Dependencies

To start using this workflow, you must set the environment variable apikey, which you can get by creating a new OpenAI account. See also the Configuration section below.

You will also need to install the pandoc command. This will allow this workflow to convert the Markdown response from OpenAI to HTML and display the result in your default web browser with syntax highlighting enabled (especially useful when using this workflow to generate program code).

Installing Pandoc will be just a few clicks once this workflow has been included in the Alfred Gallery. For now, install Pandoc using homebrew. Once homebrew is installed, run the following command.

  brew install pandoc

How to Execute This Workflow

πŸ“‹ Using Selected Text

You can select any text on your Mac and send it to the workflow:

  • Method 1: select text β†’ universal action hotkey β†’ select OpenAI Query
  • Method 2: set up a custom hotkey to Send selected text to OpenAI

⌨️ Using Alfred Textbox

You can enter a query text directly into Alfred textbox:

  • Method 1: Alfred textbox β†’ keyword (openai) β†’ tab β†’ input query text
  • Method 2: Alfred textbox β†’ input query text β†’ select fallback search (OpenAI Query)

🌐 Using Text Box in Default Web-browser

You can open a web interface (see the figure below).

  • Method 1: Alfred textbox β†’ keyword (openai-textbox)
  • Method 2: set up a custom hotkey to Open web interface

SCR-20221207-st2

General Query

The input text is used as a prompt to the OpenAI text-completion API. The original input text can be prepended or postfixed with instructional text to compose a complex query to be given to the API.

Direct Query

The input text is directly sent as a prompt to the OpenAI text-completion API.

Prepend Text + Query

After the initial text is entered, the user is prompted for additional text. The additional text is added before the initial text, and the resulting text is used as the query.

Append Text + Query

After the initial text is entered, the user is prompted for additional text. The additional text is added after the initial text and the resulting text is used as the query.

Generate Image

The DALL-E API is used to generate images according to the prompts entered. In general, the more detailed the prompt, the closer the content and quality of the output image will be to what is desired.

Rugby players are playing in a match using a huge watermelon as a ball

When the Enhance Prompt option is enabled, a short prompt, for example the following, is expanded by GPT into more detailed text, which is then used to generate images.

View of downtown Austin from across the river

Write Program Code

GPT will generate program code and example output according to the text entered. Specify the purpose of the program, its function, the language and technology to be used, etc.

Example Input

Create a command line program that takes an English sentence and returns syntactically parsed output. Provide program code in Python and example usage.

Example Output

More Specific Commands

These are features mainly based on OpenAI's example usage of its text-completion API. The user-specified values to the following user settings are ignored when running these commands:

  • temperature
  • frequency_penalty
  • presence_penalty

Language-related

Ask in Your Language

You can ask questions in the language set to the variable first_language.

Note: If the value of first_language is not English (e.g. Japanese), the query may result in a more or less inaccurate response.

Translate L1 to L2

Translate text in the language specified in the variable first_language to the language specified in the second_language.

Translate L2 to L1

Translate text in the language specified in the variable second_language to the language specified in the variable first_language.

Grammar Correction

Correct sentences into standard English. See OpenAI's description.

Idea-related

Brainstorm

Brainstorm some ideas about a given text.

Create Study Notes

Provide a topic and get study notes. See OpenAI's description for this example.

Analogy Maker

Create analogies. See OpenAI's description for this example.

Essay Outline

Generate an outline for a research topic. See OpenAI's description for this example.

Summarization-related

TL;DR Summarization

Summarize text by adding a 'tl;dr:' to the end of a text passage. See OpenAI's description for this example.

Summarize for a 2nd Grader

Translates complex text into more straightforward concepts. See OpenAI's description for this example.

Keywords

Extract keywords from a block of text. See OpenAI's description for this example.

Check API Usage

You can check how many tokens you have used in the current billing period on OpenAI Usage Page--type in the keyword openai-usage. See also OpenAI's Billing page.

Configuration

Required Settings

  • OpenAI API Key: Set your secret API key for OpenAI. Sign up for OpenAI and get your API key at https://platform.openai.com/account/api-keys/.
  • Model: OpenAI's chat/completion model that generates the completion. (default: gpt-3.5-turbo)
  • Base URL: The base URL of the OpenAI chat/completion API. (default: https://api.openai.com/v1)

Text Query Parameters

Image Generation Parameters

  • Number of Images: Set the number of images to generate in image generation mode from 1 to 10. (default: 1)
  • Image Size: Set the size of images to generate from 256x256, 512x512, 1024x1024. (default: 512x512)
  • Enhance Prompt: When enabled, the prompt to the image generation API is automatically enhanced using a GPT-4 model specified in the configuration. This variable is only enabled when the model is set to one of the "gpt-4" series.

Optional Settings

  • Your First Language: Set your first language. This language is used when using GPT for translation. (default: English)
  • Your Second Language: Set your second language. This language is used when using GPT for translation.(default: Japanese)
  • Max Characters: Maximum number of characters that can be included in a query (default: 10000).
  • Timeout: Number of seconds before the timeout (default: 180).
  • "Please Wait" Message: If disabled, the "Please Wait" message is suppressed. (default: enabled)
  • Sound: If checked, a notification sound will play when the response is returned. (default: disabled)
  • Echo: If enabled, the original prompt is contained in the result text. (default: enabled)
  • Save File Path: If set, the results will be saved in the specified path as a markdown file. (default: not set)
  • Text to Speech: If enabled, the results will be read aloud using the system's default text-to-speech language and voice. (default: disabled)
  • Output HTML Using Pandoc: Show results in the default web browser if pandoc is installed. If unchecked (or Pandoc is not installed), Alfred's "Large Type" feature is used to display the result. (default: enabled)
  • Custom CSS: You can specify CSS for the query results HTML. (default: not set)

Text to Speech

If the Text to Speech option is enabled, the result text will be read aloud in the system's standard language and voice. To change the language and speech, go to [Accessibility] - [Vision] -[Spoken Content] in the Mac Settings panel.

spoken-content-panel

Custom CSS

You can define the CSS for the HTML that will be displayed as a result of the query. For example, you can freely change the maximum text width, font size and type, background color, etc.

2023-05-13_20-53-34

Author

Yoichiro Hasebe ([email protected])

License

The MIT License

Disclaimer

The author of this software takes no responsibility for any damage that may result from using it.

More Repositories

1

engtagger

English Part-of-Speech Tagger Library; a Ruby port of Lingua::EN::Tagger
Ruby
258
star
2

wp2txt

A command-line toolkit to extract text content and category data from Wikipedia dump files
Ruby
170
star
3

lemmatizer

Lemmatizer for text in English. Inspired by Python's nltk.corpus.reader.wordnet.morphy
Ruby
109
star
4

rsyntaxtree

Syntax tree generator for linguistic research
Ruby
96
star
5

whisper-stream

A bash script using OpenAI Whisper API for continuous audio transcription with automatic silence detection
Shell
71
star
6

ruby-spacy

A wrapper module for using spaCy natural language processing library from the Ruby programming language via PyCall
Ruby
59
star
7

fzf-alfred-workflow

An Alfred workflow fo fuzzy find files/directories using fzf and fd.
53
star
8

deepl-alfred-translate-rewrite-workflow

An Alfred workflow to help translate and rewrite text using DeepL API
31
star
9

monadic-chat

πŸ€– + 🐳 + 🐧 Monadic Chat is a framework designed to create and use intelligent chatbots. By providing a full-fledged Linux environment on Docker to GPT-4 and other LLMs, it allows the chatbots to perform advanced tasks that require external tools for searching, coding, testing, analysis, visualization, and more.
Ruby
20
star
10

fastmail-plus

A Chrome extension to make Fastmail web UI more usable and productive
JavaScript
20
star
11

vim-command-workflow

An Alfred workflow to search Vim command cheat sheet + type commands
Ruby
18
star
12

rginger

RGinger takes an English sentence and gives correction and rephrasing suggestions for it using Ginger proofreading API.
Ruby
17
star
13

monadic-chat-cli

Highly configurable CLI app for OpenAI's chat/text completion API
Ruby
11
star
14

rubyfca

Command line tool for Formal Concept Analysis written in Ruby
Ruby
7
star
15

finder-unclutter

An Alfred 🎩 workflow that removes duplicate Finder tabs and windows and arranges them into a single or dual-pane πŸ‘“ layout for a cleaner desktop experience πŸ–₯️ 🧹
5
star
16

code-packager

πŸ“¦ A bash script that packages your codebase into a single JSON file, ready to be analyzed and understood by large language models (LLMs) like GPT-4, Claude, Command R, and Gemini πŸ€–
Shell
5
star
17

rubyplb

Command line Pattern Lattice building tool written in Ruby
Ruby
4
star
18

paradocs

Paradocs: A Paragraph-Oriented Text Document Presentation System
4
star
19

objective-wordnet

3
star
20

mac-dictionary-selector

An Alfred3 Workflow that lets you quickly look up words from a variety of dictionaries preinstalled in OSX
Ruby
3
star
21

ruby-wordle

A set of ruby scripts to generate word-lists, solve Wordle and play Wordle
Ruby
2
star
22

quickanswers

QuickAnswers
JavaScript
1
star
23

rsyntaxtree_web

JavaScript
1
star
24

speak_slow

SpeakSlow modifies audio files adding pauses and/or altering speed to suit for language study
Ruby
1
star