An OpenAI-powered AI CLI demo with local config management.
Project description
32r4-cli-demo
32r4-cli-demo 是一个用 Typer 构建的 OpenAI AI CLI 示例项目。当前版本支持通过固定位置的本地 .env 配置文件管理 api_key、base_url、model,并通过 OpenAI Responses API 发起一次性文本问答调用。
安装
推荐使用 uv tool 安装:
uv tool install 32r4-cli-demo
在正式发布到 PyPI 之前,也可以直接从 GitHub 安装:
uv tool install git+https://github.com/32r4/cli-demo.git
配置
推荐直接用 CLI 管理配置文件。
查看当前配置:
cli-demo config show
cli-demo config path
当前配置文件固定路径:
C:\Users\26707\.cli-demo\.env
这个路径不能通过命令或环境变量修改。
设置配置:
cli-demo config set --api-key "your-api-key"
cli-demo config set --base-url "https://api.openai.com/v1"
cli-demo config set --model "gpt-5.4"
也可以一次设置多个值:
cli-demo config set --api-key "your-api-key" --base-url "https://api.openai.com/v1" --model "gpt-5.4"
清除某个配置项:
cli-demo config unset api-key
cli-demo config unset base-url
cli-demo config unset model
说明:
api_key、base_url、model都保存在本地配置文件中。- 配置文件固定保存在
C:\Users\26707\.cli-demo\.env。 - 直接运行
cli-demo config set会进入交互式设置。 - 如果配置文件里没有
api_key,程序仍会回退到OPENAI_API_KEY环境变量。 - 如果配置文件里没有
base_url,程序仍会回退到OPENAI_BASE_URL环境变量。 - 如果配置文件里没有
model,默认使用gpt-5.4。
使用
cli-demo
cli-demo --help
cli-demo --version
cli-demo -v
cli-demo ask "Say hello in one sentence."
cli-demo ask "Explain Typer briefly." --system "You are a concise CLI tutor."
cli-demo ask "Hello" --model gpt-5.4-mini
cli-demo doctor
cli-demo doctor --no-ping
cli-demo chat
cli-demo chat --system "You are a concise CLI tutor."
cli-demo update
cli-demo ask PROMPT
向 OpenAI 发起一次文本问答请求。
cli-demo ask "Say hello in one sentence."
cli-demo ask "Explain Typer briefly." --system "You are a concise CLI tutor."
cli-demo ask "Hello" --model gpt-5.4-mini
可用参数:
PROMPT:必填位置参数--model:可选模型覆盖,优先级高于配置文件--system/-s:可选系统提示词
cli-demo doctor
Check local config, dependencies, and optional API connectivity.
cli-demo doctor
cli-demo doctor --no-ping
cli-demo doctor --model gpt-5.4-mini
Notes:
- By default it performs one minimal API connectivity check.
--no-pingskips the network request and only validates local setup.- Output includes the effective
api_key,base_url,model,uv, andopenaipackage status.
cli-demo chat
Start an interactive multi-turn chat session.
cli-demo chat
cli-demo chat --model gpt-5.4-mini
cli-demo chat --system "You are a concise CLI tutor."
Session commands:
/help/clear/history/retry/model/exit/quit
In an interactive terminal, cli-demo chat opens with a colorful welcome card and renders prompts and replies as styled message blocks. The chat prompt is a lightweight inline REPL, not a fixed input box.
When input or output is piped, chat falls back to plain text instead of launching the richer interactive UI.
cli-demo --version
显示当前 CLI 版本和生效中的模型。
cli-demo --version
cli-demo -v
cli-demo update
使用 uv tool 升级当前 CLI。
cli-demo update
cli-demo update --dry-run
说明:
cli-demo update会执行uv tool upgrade 32r4-cli-democli-demo update --dry-run只展示命令,不执行
发布到 PyPI
仓库已经包含 GitHub Actions 发布工作流 release.yml,使用 PyPI Trusted Publishing。
首次发布前,你还需要在 PyPI 做一次配置:
- 在 PyPI 创建
32r4-cli-demo项目或添加 Trusted Publisher。 - Publisher 类型选择 GitHub。
- 仓库填写
32r4/cli-demo。 - Workflow 文件名填写
release.yml。 - Environment 填写
pypi。
配置完成后,发布方式会自动完成:
git tag v0.4.4
git push origin v0.4.4
推送 tag 后,GitHub Actions 会自动:
- 创建对应的 GitHub Release
- 自动生成 Release Notes
- 发布到 PyPI
也可以在 GitHub Actions 页面手动触发 release 工作流。
本地验证
uv sync
uv build
uv run cli-demo --help
uv run cli-demo --version
uv run cli-demo -v
uv run cli-demo config show
uv run cli-demo config set --model gpt-5.4-mini
uv run cli-demo ask " "
uv run cli-demo doctor --no-ping
Write-Output '/exit' | uv run cli-demo chat
uv run cli-demo update --dry-run
uv run python -m cli_demo --help
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file 32r4_cli_demo-0.4.4.tar.gz.
File metadata
- Download URL: 32r4_cli_demo-0.4.4.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64d0feb131b384c017ef0bf5c13f6d9671d20432cc383aabf63255f29902e178
|
|
| MD5 |
3d031a3afd28bd3e4c7cdf5155f36e8b
|
|
| BLAKE2b-256 |
98a239e2bdc1824a6273edf584f6c816dda66c1d27e02a6ef21d8e5969cd4ab8
|
Provenance
The following attestation bundles were made for 32r4_cli_demo-0.4.4.tar.gz:
Publisher:
release.yml on 32r4/cli-demo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
32r4_cli_demo-0.4.4.tar.gz -
Subject digest:
64d0feb131b384c017ef0bf5c13f6d9671d20432cc383aabf63255f29902e178 - Sigstore transparency entry: 1361114780
- Sigstore integration time:
-
Permalink:
32r4/cli-demo@36c585c576985537c2e19d6d7176175699c29a5d -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/32r4
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@36c585c576985537c2e19d6d7176175699c29a5d -
Trigger Event:
push
-
Statement type:
File details
Details for the file 32r4_cli_demo-0.4.4-py3-none-any.whl.
File metadata
- Download URL: 32r4_cli_demo-0.4.4-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fdfeb2d1e869ae218ffb918384009daeab24e66796772dc5b02fe983be5646e
|
|
| MD5 |
3a2981bbe734be69d5f03ed91d379a8d
|
|
| BLAKE2b-256 |
a56c50e10ed58e8e0b89f4c943102eeb23e3daf97cef712dde824aff3b651a3c
|
Provenance
The following attestation bundles were made for 32r4_cli_demo-0.4.4-py3-none-any.whl:
Publisher:
release.yml on 32r4/cli-demo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
32r4_cli_demo-0.4.4-py3-none-any.whl -
Subject digest:
2fdfeb2d1e869ae218ffb918384009daeab24e66796772dc5b02fe983be5646e - Sigstore transparency entry: 1361114785
- Sigstore integration time:
-
Permalink:
32r4/cli-demo@36c585c576985537c2e19d6d7176175699c29a5d -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/32r4
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@36c585c576985537c2e19d6d7176175699c29a5d -
Trigger Event:
push
-
Statement type: