Skip to content

Commit

Permalink
Default to gpt-3.5, allow configuring api key from config file, adds …
Browse files Browse the repository at this point in the history
…--debug flag
  • Loading branch information
mattvr committed Apr 29, 2023
1 parent 50d6816 commit 3d399fd
Show file tree
Hide file tree
Showing 6 changed files with 749 additions and 564 deletions.
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#### [[ <img src="https://user-images.githubusercontent.com/4052466/230916740-3ca70970-67fd-45f2-9a22-c0e51e4292fc.svg" /> Introducing ShellGPT ]](https://twitter.com/matt_fvr/status/1645419221634125828)

A command-line tool that allows you to interact with GPT-4 directly from your terminal.
A command-line tool that allows you to interact with GPT-4 directly from your
terminal.

https://user-images.githubusercontent.com/4052466/230909567-3569f34c-b145-4cd8-8e55-5445bba00ba8.mp4

Expand Down Expand Up @@ -39,7 +40,8 @@ gpt "Output a CSV of 10 notable cities in Japan with their name in English & Jap

## Installation

1. Install the [Deno runtime](https://deno.land/manual/getting_started/installation).
1. Install the
[Deno runtime](https://deno.land/manual/getting_started/installation).

2. Run the following command to install ShellGPT:

Expand All @@ -64,9 +66,11 @@ using a key obtained from https://platform.openai.com/account/api-keys:
export OPENAI_API_KEY=...
```

To use the GPT-4 model (recommended as it produces much better results), you'll need to apply for access via [this link](https://openai.com/waitlist/gpt-4-api). Note that it is more expensive, however.
To use the GPT-4 model (recommended as it produces much better results), you'll
need to apply for access via [this link](https://openai.com/waitlist/gpt-4-api).
Note that it is more expensive, however.

To configure the specific ChatGPT model and system prompt used, you can type
To configure the specific ChatGPT model, system prompt used, and more, you can type
`gpt --config`

## Commands and Arguments
Expand All @@ -75,13 +79,12 @@ To configure the specific ChatGPT model and system prompt used, you can type

These commands are used for general ShellGPT-wide operations.

| Argument | Alias | Description |
| ------------- | ---------- | ---------------------------------------------------- |
| --help | | Show help |
| --config | --cfg | Configure the model and system prompt |
| --update | | Update ShellGPT to the latest version |
| --history | -h | List all past conversations |

| Argument | Alias | Description |
| --------- | ----- | ------------------------------------- |
| --help | | Show help |
| --config | --cfg | Configure the model and system prompt |
| --update | | Update ShellGPT to the latest version |
| --history | -h | List all past conversations |

### Chat Commands

Expand All @@ -107,13 +110,15 @@ These commands are for specific chats, either new or existing.
| --wpm | | Words per minute, control the speed of typing output |
| --max_tokens | --max | Maximum number of tokens to generate |
| --model | -m | Manually use a different OpenAI model |
| --debug | | Print OpenAI API information |

## Features

Shell-GPT has some useful and unique features:

- Execute shell commands with a confirmation step (just pass `-x`).
- Supports input/output piping for simple file creation and transformation (see [Basic Usage](#basic-usage)).
- Supports input/output piping for simple file creation and transformation (see
[Basic Usage](#basic-usage)).
- Utility commands for convenient chat history viewing and editing.
- Smooth, streaming output, resembling human typing rather than delayed or
choppy responses.
Expand Down Expand Up @@ -168,6 +173,7 @@ gpt --fast --wpm 1500 "How can I improve my programming skills?"
```

Interactive coding session:

```sh
gpt --code --repl "Write a typescript function that prints the first 100 primes"
```
7 changes: 7 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions lib/ai-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
export type Role = "system" | "user" | "assistant";

export interface Message {
role: Role;
content: string;
}

export interface ChatCompletionRequest {
model: 'gpt-3.5-turbo' | 'gpt-4' | string
messages: Message[];
temperature?: number;
top_p?: number;
n?: number;
stream?: boolean;
stop?: string | string[];
max_tokens?: number;
presence_penalty?: number;
frequency_penalty?: number;
logit_bias?: Record<string, number>;
user?: string;
}

export interface Choice {
index: number;
message: Message;
finish_reason: "stop" | "length" | "content_filter" | "null";
}

export interface ChatCompletionResponse {
id: string;
object: "chat.completion";
created: number;
choices: Choice[];
usage: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
}

export interface SpeechToTextRequest {
file: File;
model: 'whisper-1';
}

export interface Delta {
role?: Role;
content?: string;
}

export interface StreamChoice {
delta: Delta;
index: number;
finish_reason: "stop" | "length" | "content_filter" | "null" | null;
}

export interface ChatCompletionStreamResponse {
id: string;
object: "chat.completion.chunk";
created: number;
model: string;
choices: StreamChoice[];
}

export interface ChatCompetionStreamError {
"error": {
"message": string | null,
"type": string | null
"param": string | null
"code": string | null
}
}
Loading

0 comments on commit 3d399fd

Please sign in to comment.