Skip to main content

Interact with ChatGPT in terminal via chattool

Project description

AskChat

通过命令行运行的 ChatGPT 交互工具,随时随地调用 ChatGPT。

终端调用
hello
Jupyter Lab
jupyter

安装及配置

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 调试,对话管理等功能。

使用示例

1. API 调试
debug
2. 获取可用模型列表
validmodels
3. 多轮对话,保存对话,加载对话等
chatlog
4. 指定参数,使用不同的模型和 API
para-models

对话管理

用户保存、加载、删除和列出对话历史记录,以及继续之前的对话。

参数 示例 解释
-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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

askchat-2.1.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

askchat-2.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file askchat-2.1.0.tar.gz.

File metadata

  • Download URL: askchat-2.1.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for askchat-2.1.0.tar.gz
Algorithm Hash digest
SHA256 5a6fe1c6aef9ce1c761c41d27194aa3100871727a4592a268a8e3d813c49438c
MD5 34704ce37395b526d4005e40e318075a
BLAKE2b-256 698054c9c1f967417b6983415893516833c0011dbcb977fd2cc1a901f849dd9d

See more details on using hashes here.

File details

Details for the file askchat-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: askchat-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for askchat-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23d166a33025ae6096ba70400a6d17a2e232d8dfb0c2dc46a633bd38fc317036
MD5 31c043f7b6342f0fc03822a79eadf1ee
BLAKE2b-256 338b48f5d4bc2f64bb0dc468cc77573eab5ff55b649a1488b108ab0478f91d9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page