AskChat
通过命令行运行的 ChatGPT 交互工具,随时随地调用 ChatGPT。
安装及配置
pip install askchat --upgrade
配置环境变量:
# 初始化配置(交互式)
chatenv init -i
# 或者手动设置环境变量
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"
注:OPENAI_API_BASE 变量优先于 OPENAI_API_BASE_URL 变量,二者选一即可。
使用方法
配置完成后,进行简单的问答:
ask hello world
除此之外,可使用 askchat 进行更灵活的对话。
AskChat
askchat 支持 API 调试,对话管理等功能。
使用示例
对话管理
用户保存、加载、删除和列出对话历史记录,以及继续之前的对话。
| 参数 | 示例 | 解释 |
|---|---|---|
-c |
askchat -c <message> |
继续上一次的对话 |
--regenerate |
askchat -r |
重新生成上一次对话的最后回复 |
--load |
askchat -l <file> |
加载历史对话 |
--print |
askchat -p [<file>] |
打印上次或指定的对话历史 |
--save |
askchat -s <file> |
将当前对话历史保存到文件 |
--delete |
askchat -d <file> |
删除指定的对话历史文件 |
--list |
askchat --list |
列出所有保存的对话历史文件 |
所有对话保存在 ~/.askchat/,最近一次对话保存在 ~/.askchat/_last_chat.json。
模型参数
askchat 的默认参数,这些参数用于直接与 ChatGPT 交互或者配置 API 的连接信息。
| 参数 | 示例 | 解释 |
|---|---|---|
<message> |
askchat hello |
最简单的对话 |
--model |
-m gpt-3.5-turbo |
指定使用的模型名称 |
--base-url |
-b https://api.example.com |
设置 Base URL (不包含 /v1) |
--api-base |
--api-base https://api.example.com/v1 |
设置 Base URL |
--api-key |
-a sk-xxxxxxx |
提供 OpenAI API 密钥 |
--option |
-o top_p 1 temperature 0.5 |
设置请求参数 |
注:一些模型 API,比如智谱,使用 /v4 作为 API 的基础路径,这时得用 --api-base 参数。
其他参数
辅助功能,如生成配置文件、调试日志、打印模型列表和显示版本信息等,使用 --help 查看所有支持的参数。
| 参数 | 示例 | 解释 |
|---|---|---|
--print-url |
askchat hello --print-url |
打印实际请求的 URL |
--debug |
askchat --debug |
打印调试日志 |
--valid-models |
askchat --valid-models |
打印包含 "gpt" 名称的模型列表 |
--all-valid-models |
askchat --all-valid-models |
打印所有的模型 |
--version |
askchat -v |
askchat 的版本信息 |
注:--all-valid-models 会打印所有可用模型,包括 Embedding, dalle-3, tts 等,使用 --valid-models 可以过滤掉这些。
问题和反馈
使用过程中有任何问题或建议,欢迎提交 Issue。
Metadata
Release files for askchat 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| askchat-2.1.0.tar.gz | 1.3 MB | Without provenance | Details for askchat-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| askchat-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for askchat-2.1.0-py3-none-any.whl |
Total release size: 1.3 MB
Release files / askchat-2.1.0.tar.gz
| Download URL | askchat-2.1.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a6fe1c6aef9ce1c761c41d27194aa3100871727a4592a268a8e3d813c49438c
|
|
BLAKE2b-256 checksum How to use checksums |
698054c9c1f967417b6983415893516833c0011dbcb977fd2cc1a901f849dd9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Release files / askchat-2.1.0-py3-none-any.whl
| Download URL | askchat-2.1.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23d166a33025ae6096ba70400a6d17a2e232d8dfb0c2dc46a633bd38fc317036
|
|
BLAKE2b-256 checksum How to use checksums |
338b48f5d4bc2f64bb0dc468cc77573eab5ff55b649a1488b108ab0478f91d9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.19
|
Security for askchat 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.