commandchat 0.0.13__tar.gz → 0.0.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commandchat-0.0.15/PKG-INFO +176 -0
- commandchat-0.0.15/README.md +151 -0
- commandchat-0.0.15/commandchat.egg-info/PKG-INFO +176 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/commandchat.egg-info/SOURCES.txt +9 -1
- {commandchat-0.0.13 → commandchat-0.0.15}/commandchat.egg-info/requires.txt +4 -3
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/CommandChat.py +12 -2
- commandchat-0.0.15/occ/command/__main__.py +43 -0
- commandchat-0.0.15/occ/command/commands/__init__.py +2 -0
- commandchat-0.0.15/occ/command/commands/chat.py +453 -0
- commandchat-0.0.15/occ/command/commands/image.py +30 -0
- commandchat-0.0.15/occ/command/commands/profile.py +112 -0
- commandchat-0.0.15/occ/command/commands/prompt.py +226 -0
- commandchat-0.0.15/occ/command/interactive/__init__.py +2 -0
- commandchat-0.0.15/occ/command/interactive/profile_menu.py +91 -0
- commandchat-0.0.15/occ/command/interactive/prompt_menu.py +176 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/commons/config.py +13 -0
- commandchat-0.0.15/occ/commons/prompts.py +146 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/configuration/profile_config.py +34 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/pyproject.toml +15 -9
- commandchat-0.0.13/PKG-INFO +0 -79
- commandchat-0.0.13/README.md +0 -52
- commandchat-0.0.13/commandchat.egg-info/PKG-INFO +0 -79
- commandchat-0.0.13/occ/command/__main__.py +0 -175
- commandchat-0.0.13/setup.py +0 -31
- {commandchat-0.0.13 → commandchat-0.0.15}/LICENSE +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/commandchat.egg-info/dependency_links.txt +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/commandchat.egg-info/entry_points.txt +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/commandchat.egg-info/top_level.txt +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/ConvertLogToMarkDown.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/__init__.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/command/__init__.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/commons/__init__.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/configuration/__init__.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/utils/CommonUtil.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/utils/__init__.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/occ/utils/logger.py +0 -0
- {commandchat-0.0.13 → commandchat-0.0.15}/setup.cfg +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commandchat
|
|
3
|
+
Version: 0.0.15
|
|
4
|
+
Summary: Command-line chat client for OpenAI and Azure OpenAI models.
|
|
5
|
+
Author-email: tao <xxx.tao.c@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xoto/commandchat
|
|
8
|
+
Project-URL: Issues, https://github.com/xoto/commandchat/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: click
|
|
16
|
+
Requires-Dist: openai
|
|
17
|
+
Requires-Dist: Pillow
|
|
18
|
+
Requires-Dist: prompt_toolkit
|
|
19
|
+
Requires-Dist: Pygments
|
|
20
|
+
Requires-Dist: pyperclip
|
|
21
|
+
Requires-Dist: questionary
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: rich
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
[English](README.md) | [中文](README-zh.md)
|
|
27
|
+
|
|
28
|
+
# CommandChat
|
|
29
|
+
|
|
30
|
+
`commandchat` provides the `occ` CLI for chatting with OpenAI or Azure OpenAI models from your terminal.
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Interactive CLI chat with `occ chat`
|
|
35
|
+
- Profile-based configuration for multiple OpenAI / Azure OpenAI accounts
|
|
36
|
+
- Prompt template management with built-in and custom prompts
|
|
37
|
+
- Prompt selection per command or as a profile default
|
|
38
|
+
- Experimental image generation command
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.8+
|
|
43
|
+
- A terminal with `pip`
|
|
44
|
+
- An OpenAI-compatible API key or Azure OpenAI configuration
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip3 install commandchat
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you manage multiple Python versions locally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python3 -m pip install commandchat
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
### 1. Configure your first profile
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
occ configure
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This opens the interactive configuration flow and writes local settings under `~/.occ/`.
|
|
67
|
+
|
|
68
|
+
### 2. Start chatting
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
occ chat "Hello, introduce yourself briefly."
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can also start interactive multiline input:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
occ chat
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Inside interactive chat, you can use slash commands:
|
|
81
|
+
|
|
82
|
+
- `/` to open the shortcut command menu
|
|
83
|
+
- `/pmp`, `/p`, or `/prompt` to list prompts and switch the active prompt template
|
|
84
|
+
- `/m` or `/model` to list models and switch the active model
|
|
85
|
+
- `/q` to exit the chat session
|
|
86
|
+
- `/help` to show the help panel again
|
|
87
|
+
|
|
88
|
+
When you switch prompts with `/pmp` or models with `/m`, the CLI will ask whether you want to keep the current context or start a fresh chat session with a new session id.
|
|
89
|
+
|
|
90
|
+
Interactive chat also shows a bottom status bar with the current prompt, model, and session id.
|
|
91
|
+
|
|
92
|
+
### 3. Use prompt templates
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
occ prompt list
|
|
96
|
+
occ chat -pt translate "你好世界"
|
|
97
|
+
occ chat -pt improve "I wants to go to school yesterday"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Work with multiple profiles
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
occ configure profile -p work
|
|
104
|
+
occ configure list
|
|
105
|
+
occ chat -p work "Summarize today's priorities"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Common commands
|
|
109
|
+
|
|
110
|
+
| Command | Description |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `occ configure` | Open the interactive configuration menu |
|
|
113
|
+
| `occ configure profile -p <name>` | Create or update a profile |
|
|
114
|
+
| `occ configure list` | List configured profiles |
|
|
115
|
+
| `occ configure delete <name>` | Delete a profile |
|
|
116
|
+
| `occ chat "message"` | Send a one-off message |
|
|
117
|
+
| `occ chat` | Start an interactive chat session |
|
|
118
|
+
| `occ chat -p <profile> -m <model> "message"` | Use a specific profile/model |
|
|
119
|
+
| `occ chat -pt <prompt_key> "message"` | Chat with a predefined prompt |
|
|
120
|
+
| `occ chat` + `/` | Open the interactive shortcut menu |
|
|
121
|
+
| `occ chat` + `/pmp` / `/p` / `/prompt` | Switch prompt inside interactive chat |
|
|
122
|
+
| `occ chat` + `/m` / `/model` | Switch model inside interactive chat |
|
|
123
|
+
| `occ prompt list` | List prompt templates |
|
|
124
|
+
| `occ prompt show <key>` | Show prompt details |
|
|
125
|
+
| `occ prompt add <key> -n <name> -d <desc> -s <prompt>` | Add a custom prompt |
|
|
126
|
+
| `occ image -desc "..." -size m` | Generate images |
|
|
127
|
+
|
|
128
|
+
## Files created locally
|
|
129
|
+
|
|
130
|
+
- `~/.occ/config`: profile and model configuration
|
|
131
|
+
- `~/.occ/prompts.json`: custom prompt templates
|
|
132
|
+
|
|
133
|
+
## Packaging and PyPI
|
|
134
|
+
|
|
135
|
+
This project now uses `pyproject.toml` as the single source of truth for packaging metadata.
|
|
136
|
+
|
|
137
|
+
- `README.md` is configured as `project.readme`, so PyPI renders this file on the project page.
|
|
138
|
+
- `README-zh.md` is kept for the GitHub repository and Chinese-language documentation.
|
|
139
|
+
- To update the PyPI project page content, update `README.md`, bump the version in `pyproject.toml`, and publish a new release.
|
|
140
|
+
|
|
141
|
+
### Automatic publishing with GitHub Actions
|
|
142
|
+
|
|
143
|
+
The repository includes `.github/workflows/publish-to-pypi.yml`.
|
|
144
|
+
|
|
145
|
+
On pushes to `master` or manual runs, it will:
|
|
146
|
+
|
|
147
|
+
1. Check whether the version in `pyproject.toml` changed
|
|
148
|
+
2. Build the sdist and wheel from `pyproject.toml`
|
|
149
|
+
3. Run `twine check dist/*`
|
|
150
|
+
4. Publish to PyPI via Trusted Publishing (OIDC)
|
|
151
|
+
|
|
152
|
+
Because the package metadata points to `README.md`, each new PyPI release also refreshes the PyPI homepage description.
|
|
153
|
+
|
|
154
|
+
## Manual build
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python3 -m pip install build twine
|
|
158
|
+
python3 -m build
|
|
159
|
+
python3 -m twine check dist/*
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Uninstall
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip3 uninstall commandchat
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Feedback
|
|
169
|
+
|
|
170
|
+
- `xxx.tao.c@gmail.com`
|
|
171
|
+
- `xoto@outlook.be`
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|
|
176
|
+
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
[English](README.md) | [中文](README-zh.md)
|
|
2
|
+
|
|
3
|
+
# CommandChat
|
|
4
|
+
|
|
5
|
+
`commandchat` provides the `occ` CLI for chatting with OpenAI or Azure OpenAI models from your terminal.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Interactive CLI chat with `occ chat`
|
|
10
|
+
- Profile-based configuration for multiple OpenAI / Azure OpenAI accounts
|
|
11
|
+
- Prompt template management with built-in and custom prompts
|
|
12
|
+
- Prompt selection per command or as a profile default
|
|
13
|
+
- Experimental image generation command
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Python 3.8+
|
|
18
|
+
- A terminal with `pip`
|
|
19
|
+
- An OpenAI-compatible API key or Azure OpenAI configuration
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip3 install commandchat
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If you manage multiple Python versions locally:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python3 -m pip install commandchat
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
### 1. Configure your first profile
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
occ configure
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This opens the interactive configuration flow and writes local settings under `~/.occ/`.
|
|
42
|
+
|
|
43
|
+
### 2. Start chatting
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
occ chat "Hello, introduce yourself briefly."
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You can also start interactive multiline input:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
occ chat
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Inside interactive chat, you can use slash commands:
|
|
56
|
+
|
|
57
|
+
- `/` to open the shortcut command menu
|
|
58
|
+
- `/pmp`, `/p`, or `/prompt` to list prompts and switch the active prompt template
|
|
59
|
+
- `/m` or `/model` to list models and switch the active model
|
|
60
|
+
- `/q` to exit the chat session
|
|
61
|
+
- `/help` to show the help panel again
|
|
62
|
+
|
|
63
|
+
When you switch prompts with `/pmp` or models with `/m`, the CLI will ask whether you want to keep the current context or start a fresh chat session with a new session id.
|
|
64
|
+
|
|
65
|
+
Interactive chat also shows a bottom status bar with the current prompt, model, and session id.
|
|
66
|
+
|
|
67
|
+
### 3. Use prompt templates
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
occ prompt list
|
|
71
|
+
occ chat -pt translate "你好世界"
|
|
72
|
+
occ chat -pt improve "I wants to go to school yesterday"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 4. Work with multiple profiles
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
occ configure profile -p work
|
|
79
|
+
occ configure list
|
|
80
|
+
occ chat -p work "Summarize today's priorities"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Common commands
|
|
84
|
+
|
|
85
|
+
| Command | Description |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `occ configure` | Open the interactive configuration menu |
|
|
88
|
+
| `occ configure profile -p <name>` | Create or update a profile |
|
|
89
|
+
| `occ configure list` | List configured profiles |
|
|
90
|
+
| `occ configure delete <name>` | Delete a profile |
|
|
91
|
+
| `occ chat "message"` | Send a one-off message |
|
|
92
|
+
| `occ chat` | Start an interactive chat session |
|
|
93
|
+
| `occ chat -p <profile> -m <model> "message"` | Use a specific profile/model |
|
|
94
|
+
| `occ chat -pt <prompt_key> "message"` | Chat with a predefined prompt |
|
|
95
|
+
| `occ chat` + `/` | Open the interactive shortcut menu |
|
|
96
|
+
| `occ chat` + `/pmp` / `/p` / `/prompt` | Switch prompt inside interactive chat |
|
|
97
|
+
| `occ chat` + `/m` / `/model` | Switch model inside interactive chat |
|
|
98
|
+
| `occ prompt list` | List prompt templates |
|
|
99
|
+
| `occ prompt show <key>` | Show prompt details |
|
|
100
|
+
| `occ prompt add <key> -n <name> -d <desc> -s <prompt>` | Add a custom prompt |
|
|
101
|
+
| `occ image -desc "..." -size m` | Generate images |
|
|
102
|
+
|
|
103
|
+
## Files created locally
|
|
104
|
+
|
|
105
|
+
- `~/.occ/config`: profile and model configuration
|
|
106
|
+
- `~/.occ/prompts.json`: custom prompt templates
|
|
107
|
+
|
|
108
|
+
## Packaging and PyPI
|
|
109
|
+
|
|
110
|
+
This project now uses `pyproject.toml` as the single source of truth for packaging metadata.
|
|
111
|
+
|
|
112
|
+
- `README.md` is configured as `project.readme`, so PyPI renders this file on the project page.
|
|
113
|
+
- `README-zh.md` is kept for the GitHub repository and Chinese-language documentation.
|
|
114
|
+
- To update the PyPI project page content, update `README.md`, bump the version in `pyproject.toml`, and publish a new release.
|
|
115
|
+
|
|
116
|
+
### Automatic publishing with GitHub Actions
|
|
117
|
+
|
|
118
|
+
The repository includes `.github/workflows/publish-to-pypi.yml`.
|
|
119
|
+
|
|
120
|
+
On pushes to `master` or manual runs, it will:
|
|
121
|
+
|
|
122
|
+
1. Check whether the version in `pyproject.toml` changed
|
|
123
|
+
2. Build the sdist and wheel from `pyproject.toml`
|
|
124
|
+
3. Run `twine check dist/*`
|
|
125
|
+
4. Publish to PyPI via Trusted Publishing (OIDC)
|
|
126
|
+
|
|
127
|
+
Because the package metadata points to `README.md`, each new PyPI release also refreshes the PyPI homepage description.
|
|
128
|
+
|
|
129
|
+
## Manual build
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python3 -m pip install build twine
|
|
133
|
+
python3 -m build
|
|
134
|
+
python3 -m twine check dist/*
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Uninstall
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip3 uninstall commandchat
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Feedback
|
|
144
|
+
|
|
145
|
+
- `xxx.tao.c@gmail.com`
|
|
146
|
+
- `xoto@outlook.be`
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
MIT
|
|
151
|
+
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commandchat
|
|
3
|
+
Version: 0.0.15
|
|
4
|
+
Summary: Command-line chat client for OpenAI and Azure OpenAI models.
|
|
5
|
+
Author-email: tao <xxx.tao.c@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/xoto/commandchat
|
|
8
|
+
Project-URL: Issues, https://github.com/xoto/commandchat/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: click
|
|
16
|
+
Requires-Dist: openai
|
|
17
|
+
Requires-Dist: Pillow
|
|
18
|
+
Requires-Dist: prompt_toolkit
|
|
19
|
+
Requires-Dist: Pygments
|
|
20
|
+
Requires-Dist: pyperclip
|
|
21
|
+
Requires-Dist: questionary
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: rich
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
[English](README.md) | [中文](README-zh.md)
|
|
27
|
+
|
|
28
|
+
# CommandChat
|
|
29
|
+
|
|
30
|
+
`commandchat` provides the `occ` CLI for chatting with OpenAI or Azure OpenAI models from your terminal.
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Interactive CLI chat with `occ chat`
|
|
35
|
+
- Profile-based configuration for multiple OpenAI / Azure OpenAI accounts
|
|
36
|
+
- Prompt template management with built-in and custom prompts
|
|
37
|
+
- Prompt selection per command or as a profile default
|
|
38
|
+
- Experimental image generation command
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.8+
|
|
43
|
+
- A terminal with `pip`
|
|
44
|
+
- An OpenAI-compatible API key or Azure OpenAI configuration
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip3 install commandchat
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you manage multiple Python versions locally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python3 -m pip install commandchat
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick start
|
|
59
|
+
|
|
60
|
+
### 1. Configure your first profile
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
occ configure
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This opens the interactive configuration flow and writes local settings under `~/.occ/`.
|
|
67
|
+
|
|
68
|
+
### 2. Start chatting
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
occ chat "Hello, introduce yourself briefly."
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can also start interactive multiline input:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
occ chat
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Inside interactive chat, you can use slash commands:
|
|
81
|
+
|
|
82
|
+
- `/` to open the shortcut command menu
|
|
83
|
+
- `/pmp`, `/p`, or `/prompt` to list prompts and switch the active prompt template
|
|
84
|
+
- `/m` or `/model` to list models and switch the active model
|
|
85
|
+
- `/q` to exit the chat session
|
|
86
|
+
- `/help` to show the help panel again
|
|
87
|
+
|
|
88
|
+
When you switch prompts with `/pmp` or models with `/m`, the CLI will ask whether you want to keep the current context or start a fresh chat session with a new session id.
|
|
89
|
+
|
|
90
|
+
Interactive chat also shows a bottom status bar with the current prompt, model, and session id.
|
|
91
|
+
|
|
92
|
+
### 3. Use prompt templates
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
occ prompt list
|
|
96
|
+
occ chat -pt translate "你好世界"
|
|
97
|
+
occ chat -pt improve "I wants to go to school yesterday"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 4. Work with multiple profiles
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
occ configure profile -p work
|
|
104
|
+
occ configure list
|
|
105
|
+
occ chat -p work "Summarize today's priorities"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Common commands
|
|
109
|
+
|
|
110
|
+
| Command | Description |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `occ configure` | Open the interactive configuration menu |
|
|
113
|
+
| `occ configure profile -p <name>` | Create or update a profile |
|
|
114
|
+
| `occ configure list` | List configured profiles |
|
|
115
|
+
| `occ configure delete <name>` | Delete a profile |
|
|
116
|
+
| `occ chat "message"` | Send a one-off message |
|
|
117
|
+
| `occ chat` | Start an interactive chat session |
|
|
118
|
+
| `occ chat -p <profile> -m <model> "message"` | Use a specific profile/model |
|
|
119
|
+
| `occ chat -pt <prompt_key> "message"` | Chat with a predefined prompt |
|
|
120
|
+
| `occ chat` + `/` | Open the interactive shortcut menu |
|
|
121
|
+
| `occ chat` + `/pmp` / `/p` / `/prompt` | Switch prompt inside interactive chat |
|
|
122
|
+
| `occ chat` + `/m` / `/model` | Switch model inside interactive chat |
|
|
123
|
+
| `occ prompt list` | List prompt templates |
|
|
124
|
+
| `occ prompt show <key>` | Show prompt details |
|
|
125
|
+
| `occ prompt add <key> -n <name> -d <desc> -s <prompt>` | Add a custom prompt |
|
|
126
|
+
| `occ image -desc "..." -size m` | Generate images |
|
|
127
|
+
|
|
128
|
+
## Files created locally
|
|
129
|
+
|
|
130
|
+
- `~/.occ/config`: profile and model configuration
|
|
131
|
+
- `~/.occ/prompts.json`: custom prompt templates
|
|
132
|
+
|
|
133
|
+
## Packaging and PyPI
|
|
134
|
+
|
|
135
|
+
This project now uses `pyproject.toml` as the single source of truth for packaging metadata.
|
|
136
|
+
|
|
137
|
+
- `README.md` is configured as `project.readme`, so PyPI renders this file on the project page.
|
|
138
|
+
- `README-zh.md` is kept for the GitHub repository and Chinese-language documentation.
|
|
139
|
+
- To update the PyPI project page content, update `README.md`, bump the version in `pyproject.toml`, and publish a new release.
|
|
140
|
+
|
|
141
|
+
### Automatic publishing with GitHub Actions
|
|
142
|
+
|
|
143
|
+
The repository includes `.github/workflows/publish-to-pypi.yml`.
|
|
144
|
+
|
|
145
|
+
On pushes to `master` or manual runs, it will:
|
|
146
|
+
|
|
147
|
+
1. Check whether the version in `pyproject.toml` changed
|
|
148
|
+
2. Build the sdist and wheel from `pyproject.toml`
|
|
149
|
+
3. Run `twine check dist/*`
|
|
150
|
+
4. Publish to PyPI via Trusted Publishing (OIDC)
|
|
151
|
+
|
|
152
|
+
Because the package metadata points to `README.md`, each new PyPI release also refreshes the PyPI homepage description.
|
|
153
|
+
|
|
154
|
+
## Manual build
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python3 -m pip install build twine
|
|
158
|
+
python3 -m build
|
|
159
|
+
python3 -m twine check dist/*
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Uninstall
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip3 uninstall commandchat
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Feedback
|
|
169
|
+
|
|
170
|
+
- `xxx.tao.c@gmail.com`
|
|
171
|
+
- `xoto@outlook.be`
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|
|
176
|
+
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
|
-
setup.py
|
|
5
4
|
commandchat.egg-info/PKG-INFO
|
|
6
5
|
commandchat.egg-info/SOURCES.txt
|
|
7
6
|
commandchat.egg-info/dependency_links.txt
|
|
@@ -13,8 +12,17 @@ occ/ConvertLogToMarkDown.py
|
|
|
13
12
|
occ/__init__.py
|
|
14
13
|
occ/command/__init__.py
|
|
15
14
|
occ/command/__main__.py
|
|
15
|
+
occ/command/commands/__init__.py
|
|
16
|
+
occ/command/commands/chat.py
|
|
17
|
+
occ/command/commands/image.py
|
|
18
|
+
occ/command/commands/profile.py
|
|
19
|
+
occ/command/commands/prompt.py
|
|
20
|
+
occ/command/interactive/__init__.py
|
|
21
|
+
occ/command/interactive/profile_menu.py
|
|
22
|
+
occ/command/interactive/prompt_menu.py
|
|
16
23
|
occ/commons/__init__.py
|
|
17
24
|
occ/commons/config.py
|
|
25
|
+
occ/commons/prompts.py
|
|
18
26
|
occ/configuration/__init__.py
|
|
19
27
|
occ/configuration/profile_config.py
|
|
20
28
|
occ/utils/CommonUtil.py
|
|
@@ -9,7 +9,6 @@ from dataclasses import dataclass
|
|
|
9
9
|
|
|
10
10
|
from openai import AzureOpenAI
|
|
11
11
|
from openai import OpenAI
|
|
12
|
-
from openai.types.chat.chat_completion_chunk import Choice
|
|
13
12
|
from prompt_toolkit import print_formatted_text, HTML, Application
|
|
14
13
|
from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard
|
|
15
14
|
from prompt_toolkit.layout import Layout, HSplit
|
|
@@ -58,7 +57,7 @@ class CommandChat:
|
|
|
58
57
|
partial_text = []
|
|
59
58
|
role = None
|
|
60
59
|
|
|
61
|
-
def __init__(self, profile=None, chat_log_id=None, model=None):
|
|
60
|
+
def __init__(self, profile=None, chat_log_id=None, model=None, system_message=None):
|
|
62
61
|
now = time.strftime("%Y%m%d", time.localtime())
|
|
63
62
|
self.profile = profile or DEFAULT_PROFILE
|
|
64
63
|
self.api_server_type = get_env(self.profile, "api_server_type")
|
|
@@ -92,6 +91,17 @@ class CommandChat:
|
|
|
92
91
|
except json.JSONDecodeError:
|
|
93
92
|
continue
|
|
94
93
|
|
|
94
|
+
# Add system message if provided
|
|
95
|
+
if system_message:
|
|
96
|
+
# Check if there's already a system message at the beginning
|
|
97
|
+
has_system = len(self.messages) > 0 and self.messages[0].get('role') == 'system'
|
|
98
|
+
if has_system:
|
|
99
|
+
# Replace existing system message
|
|
100
|
+
self.messages[0] = {"role": "system", "content": system_message}
|
|
101
|
+
else:
|
|
102
|
+
# Insert system message at the beginning
|
|
103
|
+
self.messages.insert(0, {"role": "system", "content": system_message})
|
|
104
|
+
|
|
95
105
|
# Initialize client based on API server type
|
|
96
106
|
if self.api_server_type == "azure-openai":
|
|
97
107
|
# For Azure OpenAI, we'll initialize client per model in chat method
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OpenAI CommandChat - Command Line Interface
|
|
3
|
+
|
|
4
|
+
Main entry point for the occ CLI tool.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import absolute_import
|
|
8
|
+
|
|
9
|
+
import importlib.metadata
|
|
10
|
+
import click
|
|
11
|
+
|
|
12
|
+
# Import command modules
|
|
13
|
+
from occ.command.commands.prompt import prompt
|
|
14
|
+
from occ.command.commands.profile import configure
|
|
15
|
+
from occ.command.commands.chat import chat
|
|
16
|
+
from occ.command.commands.image import image
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
VERSION = importlib.metadata.version("commandchat")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@click.group()
|
|
23
|
+
@click.version_option(version=VERSION, prog_name='openai-commandchat')
|
|
24
|
+
def cli():
|
|
25
|
+
"""OpenAI CommandChat - AI-powered command-line chat tool"""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Register commands
|
|
30
|
+
cli.add_command(configure)
|
|
31
|
+
cli.add_command(chat)
|
|
32
|
+
cli.add_command(prompt)
|
|
33
|
+
cli.add_command(image)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def main():
|
|
37
|
+
"""Main entry point"""
|
|
38
|
+
cli()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__ == '__main__':
|
|
42
|
+
main()
|
|
43
|
+
|