Skip to content

Latest commit

 

History

History
221 lines (163 loc) · 8.13 KB

README-en.md

File metadata and controls

221 lines (163 loc) · 8.13 KB

AskChat

AskChat is a command-line tool for ChatGPT interaction, allowing you to call ChatGPT anytime, anywhere.

Run in Terminal
hello
Jupyter Lab
jupyter

Installation and Configuration

pip install askchat --upgrade

Configure environment variables:

export OPENAI_API_KEY="your-api-key"
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_API_BASE_URL="https://api.openai.com"
export OPENAI_API_MODEL="gpt-3.5-turbo"

Note: The OPENAI_API_BASE variable takes precedence over the OPENAI_API_BASE_URL variable; choose one.

How to Use

Use environment variables for simple question and answer:

ask hello world

In addition, you can use askchat for more flexible dialogue and askenv to manage environment configurations.

AskChat

askchat supports API debugging, dialogue management, and other functionalities.

Usage Examples

1. API debugging
debug
2. Get a list of available models
validmodels
3. Multi-turn dialogue, saving dialogues, loading dialogues, etc.
chatlog
4. Specify parameters, using different models and APIs
para-models

Dialogue Management

Users save, load, delete, and list dialogue histories, as well as continue previous dialogues.

Parameter Example Explanation
-c askchat -c <message> Continue the last conversation
--regenerate askchat -r Regenerate the last reply in a conversation
--load askchat -l <file> Load historical dialogues
--print askchat -p [<file>] Print the last or a specified dialogue history
--save askchat -s <file> Save the current dialogue history to a file
--delete askchat -d <file> Delete a specified dialogue history file
--list askchat --list List all saved dialogue history files

All dialogues are saved in ~/.askchat/, with the most recent dialogue saved in ~/.askchat/_last_chat.json.

Model Parameters

Default parameters for askchat, these are used for direct interaction with ChatGPT or to configure API connection info.

Parameter Example Explanation
<message> askchat hello Simplest form of dialogue
--model -m gpt-3.5-turbo Specify the model to be used
--base-url -b https://api.example.com Set the Base URL (excluding /v1)
--api-base --api-base https://api.example.com/v1 Set the Base URL
--api-key -a sk-xxxxxxx Provide the OpenAI API key
--option -o top_p 1 temperature 0.5 Set request parameters
--use-env -u prod Load environment variables from a specified config, see AskEnv

Note: Some model APIs, such as Zhishu, use /v4 as the API base path, in which case use the --api-base parameter.

Additional Parameters

Auxiliary features, such as generating configuration files, debugging logs, printing model lists, and showing version information, etc., use --help to see all supported parameters.

Parameter Example Explanation
--generate-config askchat --generate-config Generate a configuration file, saved in ~/.askchat/.env
--print-curl askchat hello --print-curl Print the actual request URL
--debug askchat --debug Print debugging logs
--valid-models askchat --valid-models Print a list of models containing "gpt" in their names
--all-valid-models askchat --all-valid-models Print all available models
--version askchat -v Version information of askchat

Note: --all-valid-models will print all available models, including Embedding, dalle-3, tts, etc., use --valid-models to filter these out.

AskEnv

askenv is used to manage different environment configurations, including creating, activating, deleting, etc., making it easy to switch between different channels.

Examples

1. Create channel
askenv
2. Edit channel
editenv

Basic Usage

  1. Create a new environment configuration using the new command.

    askenv new <name> [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]

    Or generate a default config from environment variables using askchat --generate-config:

    askchat --generate-config
  2. Activate a certain environment, setting it as the currently used configuration.

    askenv use <name>
  3. Delete a specified environment configuration file.

    askenv delete <name>
    askenv delete --default
  4. List all currently available environments.

    askenv list
  5. Show configuration info of a specified environment, or the default environment if no name is specified.

    askenv show [name]
  6. Save the currently activated environment configuration as a specified name's configuration file.

    askenv save <name>
  7. Update one or more settings of a specified or default environment configuration.

    askenv config [name] [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]

Issues and Feedback

If you encounter any problems or have suggestions, feel free to submit an Issue.