answer

Crates.ioanswer
lib.rsanswer
version0.0.1-beta.1
sourcesrc
created_at2023-03-14 02:15:26.207579
updated_at2023-03-15 19:16:39.799486
descriptionanswer any question right from your terminal, using the same large language model that powers ChatGPT
homepagehttps://github.com/schneiderfelipe/answer
repository
max_upload_size
id809404
size60,042
Felipe S. S. Schneider (schneiderfelipe)

documentation

README

answer

Crates.io Crates.io CI Changelog

answer any question right from your terminal, using the same large language model that powers ChatGPT.

$ echo "🌭 = 🥪?" | answer
No, a hot dog (🌭) is not the same as a sandwich (🥪).
While they both consist of bread and a filling,
a sandwich typically has separate slices of bread,
while a hot dog has a single bun that is sliced
on the top and filled with a sausage.

Read the installation and usage instructions below.

Installation

From source (recommended)

Either clone the repository to your machine and install from it, or install directly from GitHub. Both options require Rust and Cargo to be installed.

# Option 1: cloning and installing from the repository
$ git clone https://github.com/schneiderfelipe/answer.git
$ cd answer && cargo install --path=answer/

# Option 2: installing directly from GitHub
$ cargo install --git=https://github.com/schneiderfelipe/answer

Environment Setup

Before using answer, you need to set up your environment to use OpenAI's chat completion API (the same technology that powers OpenAI's most advanced language model, ChatGPT). To set up your environment, you'll need to have a secret API key from OpenAI, which can be obtained at OpenAI's online platform.

Next, set an environment variable in your shell as follows:

export OPENAI_API_KEY="sk-...a1b2"

Usage

With your environment set up, you're ready to start using the command-line application. Here's an example:

$ echo "Date of birth of Malcolm X?" | answer
The date of birth of Malcolm X is May 19, 1925.

You can also get answers in context by providing a YAML file containing the initial part of a chat history. For example:

# birthdates.yml
messages:
  - role: system
    content: >-
      You are a date of birth checker.
      Given the name of a person,
      your job is to specify the date of birth of said person.
$ echo "Malcolm X" | answer birthdates.yml
Malcolm X was born on May 19th, 1925.

The file format closely resembles both OpenAI's higher-level API and its lower-level ChatML format.

Unsafe code usage

This project forbids unsafe code usage.

License: MIT

Commit count: 0

cargo fmt