AskChat is a command-line tool for ChatGPT interaction, allowing you to call ChatGPT anytime, anywhere.
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.
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
supports API debugging, dialogue management, and other functionalities.
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
.
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.
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
is used to manage different environment configurations, including creating, activating, deleting, etc., making it easy to switch between different channels.
-
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
-
Activate a certain environment, setting it as the currently used configuration.
askenv use <name>
-
Delete a specified environment configuration file.
askenv delete <name> askenv delete --default
-
List all currently available environments.
askenv list
-
Show configuration info of a specified environment, or the default environment if no name is specified.
askenv show [name]
-
Save the currently activated environment configuration as a specified name's configuration file.
askenv save <name>
-
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]
If you encounter any problems or have suggestions, feel free to submit an Issue.