Skip to content

Latest commit

 

History

History
152 lines (115 loc) · 6.24 KB

File metadata and controls

152 lines (115 loc) · 6.24 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:

# Initialize configuration (interactive)
chatenv init -i

# Or manually set 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

After configuration, use environment variables for simple question and answer:

ask hello world

In addition, you can use askchat for more flexible dialogue.

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

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
--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.

Issues and Feedback

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