https://github.com/freesrz93/ask-gpt
A CLI tool to chat with OpenAI LLMs via API. Support custom roles, conversation history and streaming output.
https://github.com/freesrz93/ask-gpt
chatgpt cli go golang gpt gpt-cli openai openai-api openai-cli
Last synced: 5 months ago
JSON representation
A CLI tool to chat with OpenAI LLMs via API. Support custom roles, conversation history and streaming output.
- Host: GitHub
- URL: https://github.com/freesrz93/ask-gpt
- Owner: freesrz93
- License: mit
- Created: 2024-08-07T09:02:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-06T05:08:24.000Z (over 1 year ago)
- Last Synced: 2025-01-06T06:19:38.114Z (over 1 year ago)
- Topics: chatgpt, cli, go, golang, gpt, gpt-cli, openai, openai-api, openai-cli
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ask GPT
English | [简体中文](./README_ZH.md)
Ask GPT is a CLI tool to chat with OpenAI LLMs via API.
## Features
- **Custom Roles**: Customise multi roles, each with its own system prompt.
- **Save/Retrieve Conversations**: Save conversations locally and continue it seamlessly in the future.
- **Streaming Output**: See the output instantly after an input, no need to wait for completion.
- **Support Pipeline**: Send any output of other CLI tools to AI via pipeline.
- **Interactive mode**: Chat with AI interactively. Offer a user experience similar to the web-based ChatGPT.
- **Support Models**: Compatibility with all models accessible through the OpenAI API.
- **Edit Config Easily**: One-click access to configuration file for easy setup and customization.
## Installation
Download the pre-built binary from [release](https://github.com/freesrz93/ask-gpt/releases/latest) and add it to path.
## Usage
1. Run ask-gpt for the first time:
```shell
ag -v
```
and the app will create the config file at
```
%USERPROFILE%/.config/ask-gpt/config.yaml
```
for Windows and
```
$HOME/.config/ask-gpt/config.yaml
```
for Linux and macOS.
2. Edit the config. See [Configuration](#configuration) for detail.
3. Quickly ask a question:
```shell
ag "what's the best programming language in the world?"
```
4. To create or continue a conversation, use `-s`:
```shell
ag -s "chat 1" "Tell a story"
```
5. To chat interactively, use `-i`:
```shell
ag -i "Translate the given sentences to Chinese"
```
`-s` can be used with `-i`:
```shell
ag -s "translation" -i "Translate the given sentences to Chinese"
```
6. Use pipeline:
```shell
cat raw.txt | ag -i "Translate above contents to Chinese"
```
7. To create a new role, use `-n`:
```shell
ag -n
```
then set its name, description and prompt interactively.
8. To use a role, use `-r` (the role should already exist):
```shell
ag -r "translator" -i "Translate the given sentences to Chinese"
```
`-r` can be used with `-s` but only valid when creating a conversation.
9. To show history of the conversation, use `-h`:
```shell
ag -s "translation" -h -i
```
this will print previous messages and continue with interactive mode.
10. For more usage, see:
```shell
chatgpt --help
```
## Configuration
| Name | Meaning | Default |
|-------------------|------------------------------------------------------------------------------------------------------------|-----------------------------|
| url | The base URL for OpenAI API. | "https://api.openai.com/v1" |
| api_key | Your OpenAI API key. | "" |
| model | The model to be used. | "gpt-4o-mini" |
| max_tokens | The maximum token cost in a single API call. | 4096 |
| temperature | See [OpenAI Doc](https://platform.openai.com/docs/api-reference/chat/create#chat-create-temperature) | 0.5 |
| top_p | See [OpenAI Doc](https://platform.openai.com/docs/api-reference/chat/create#chat-create-top_p) | 1.0 |
| frequency_penalty | See [OpenAI Doc](https://platform.openai.com/docs/api-reference/chat/create#chat-create-frequency_penalty) | 0 |
| presence_penalty | See [OpenAI Doc](https://platform.openai.com/docs/api-reference/chat/create#chat-create-presence_penalty) | 0 |
| editor | The editor to be used to edit config file. Must in path. | "code" |
| editor_arg | The arguments to be passed to the editor. `%path` will be replaced by the actual path. | "%path" |