ngpt 1.1.3__py3-none-any.whl → 1.1.4__py3-none-any.whl
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.
- ngpt/client.py +1 -1
- ngpt/config.py +33 -13
- {ngpt-1.1.3.dist-info → ngpt-1.1.4.dist-info}/METADATA +35 -2
- ngpt-1.1.4.dist-info/RECORD +9 -0
- ngpt-1.1.3.dist-info/RECORD +0 -9
- {ngpt-1.1.3.dist-info → ngpt-1.1.4.dist-info}/WHEEL +0 -0
- {ngpt-1.1.3.dist-info → ngpt-1.1.4.dist-info}/entry_points.txt +0 -0
- {ngpt-1.1.3.dist-info → ngpt-1.1.4.dist-info}/licenses/LICENSE +0 -0
ngpt/client.py
CHANGED
@@ -10,7 +10,7 @@ class NGPTClient:
|
|
10
10
|
self,
|
11
11
|
api_key: str = "",
|
12
12
|
base_url: str = "https://api.openai.com/v1/",
|
13
|
-
provider: str = "OpenAI",
|
13
|
+
provider: str = "OpenAI",
|
14
14
|
model: str = "gpt-3.5-turbo"
|
15
15
|
):
|
16
16
|
self.api_key = api_key
|
ngpt/config.py
CHANGED
@@ -51,23 +51,44 @@ def add_config_entry(config_path: Path, config_index: Optional[int] = None) -> N
|
|
51
51
|
"""Add a new configuration entry or update existing one at the specified index."""
|
52
52
|
configs = load_configs(custom_path=str(config_path))
|
53
53
|
|
54
|
-
#
|
55
|
-
|
54
|
+
# Determine if we're editing an existing config or creating a new one
|
55
|
+
is_existing_config = config_index is not None and config_index < len(configs)
|
56
|
+
|
57
|
+
# Set up entry based on whether we're editing or creating
|
58
|
+
if is_existing_config:
|
59
|
+
# Use existing config as the base when editing
|
60
|
+
entry = configs[config_index].copy()
|
61
|
+
print("Enter configuration details (press Enter to keep current values):")
|
62
|
+
else:
|
63
|
+
# Use default config as the base when creating new
|
64
|
+
entry = DEFAULT_CONFIG_ENTRY.copy()
|
65
|
+
print("Enter configuration details (press Enter to use default values):")
|
56
66
|
|
57
|
-
# Interactive configuration
|
58
|
-
print("Enter configuration details (press Enter to use default values):")
|
59
67
|
try:
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
68
|
+
# For API key, just show the prompt without the current value for security
|
69
|
+
user_input = input(f"API Key: ")
|
70
|
+
if user_input:
|
71
|
+
entry["api_key"] = user_input
|
72
|
+
|
73
|
+
# For other fields, show current/default value and keep it if Enter is pressed
|
74
|
+
user_input = input(f"Base URL [{entry['base_url']}]: ")
|
75
|
+
if user_input:
|
76
|
+
entry["base_url"] = user_input
|
77
|
+
|
78
|
+
user_input = input(f"Provider [{entry['provider']}]: ")
|
79
|
+
if user_input:
|
80
|
+
entry["provider"] = user_input
|
81
|
+
|
82
|
+
user_input = input(f"Model [{entry['model']}]: ")
|
83
|
+
if user_input:
|
84
|
+
entry["model"] = user_input
|
64
85
|
|
65
86
|
# Add or update the entry
|
66
|
-
if
|
67
|
-
configs[config_index] =
|
87
|
+
if is_existing_config:
|
88
|
+
configs[config_index] = entry
|
68
89
|
print(f"Updated configuration at index {config_index}")
|
69
90
|
else:
|
70
|
-
configs.append(
|
91
|
+
configs.append(entry)
|
71
92
|
print(f"Added new configuration at index {len(configs)-1}")
|
72
93
|
|
73
94
|
# Save the updated configs
|
@@ -128,8 +149,7 @@ def load_config(custom_path: Optional[str] = None, config_index: int = 0) -> Dic
|
|
128
149
|
# Override with environment variables if they exist
|
129
150
|
env_mapping = {
|
130
151
|
"OPENAI_API_KEY": "api_key",
|
131
|
-
"OPENAI_BASE_URL": "base_url",
|
132
|
-
"OPENAI_PROVIDER": "provider",
|
152
|
+
"OPENAI_BASE_URL": "base_url",
|
133
153
|
"OPENAI_MODEL": "model"
|
134
154
|
}
|
135
155
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.4
|
4
4
|
Summary: A lightweight Python CLI and library for interacting with OpenAI-compatible APIs, supporting both official and self-hosted LLM endpoints.
|
5
5
|
Project-URL: Homepage, https://github.com/nazdridoy/ngpt
|
6
6
|
Project-URL: Repository, https://github.com/nazdridoy/ngpt
|
@@ -48,8 +48,10 @@ A lightweight Python CLI and library for interacting with OpenAI-compatible APIs
|
|
48
48
|
- [Python Library](#as-a-library)
|
49
49
|
- [Configuration](#configuration)
|
50
50
|
- [Command Line Options](#command-line-options)
|
51
|
+
- [Interactive Configuration](#interactive-configuration)
|
51
52
|
- [Configuration File](#configuration-file)
|
52
53
|
- [Configuration Priority](#configuration-priority)
|
54
|
+
- [Contributing](#contributing)
|
53
55
|
- [License](#license)
|
54
56
|
|
55
57
|
## Quick Start
|
@@ -191,7 +193,7 @@ You can configure the client using the following options:
|
|
191
193
|
| `--base-url` | Base URL for the API |
|
192
194
|
| `--model` | Model to use |
|
193
195
|
| `--web-search` | Enable web search capability |
|
194
|
-
| `--config` | Path to a custom configuration file |
|
196
|
+
| `--config` | Path to a custom configuration file or, when used without a value, enters interactive configuration mode |
|
195
197
|
| `--config-index` | Index of the configuration to use (default: 0) |
|
196
198
|
| `--show-config` | Show configuration details and exit |
|
197
199
|
| `--all` | Used with `--show-config` to display all configurations |
|
@@ -199,6 +201,23 @@ You can configure the client using the following options:
|
|
199
201
|
| `-c, --code` | Generate clean code output |
|
200
202
|
| `-v, --version` | Show version information |
|
201
203
|
|
204
|
+
### Interactive Configuration
|
205
|
+
|
206
|
+
The `--config` option without arguments enters interactive configuration mode, allowing you to add or edit configurations:
|
207
|
+
|
208
|
+
```bash
|
209
|
+
# Add a new configuration
|
210
|
+
ngpt --config
|
211
|
+
|
212
|
+
# Edit an existing configuration at index 1
|
213
|
+
ngpt --config --config-index 1
|
214
|
+
```
|
215
|
+
|
216
|
+
In interactive mode:
|
217
|
+
- When editing an existing configuration, press Enter to keep the current values
|
218
|
+
- When creating a new configuration, press Enter to use default values
|
219
|
+
- For security, your API key is not displayed when editing configurations
|
220
|
+
|
202
221
|
### Configuration File
|
203
222
|
|
204
223
|
nGPT uses a configuration file stored in the standard user config directory for your operating system:
|
@@ -242,6 +261,20 @@ nGPT determines configuration values in the following order (highest priority fi
|
|
242
261
|
3. Configuration file (selected by `--config-index`, defaults to index 0)
|
243
262
|
4. Default values
|
244
263
|
|
264
|
+
## Contributing
|
265
|
+
|
266
|
+
We welcome contributions to nGPT! Whether it's bug fixes, feature additions, or documentation improvements, your help is appreciated.
|
267
|
+
|
268
|
+
To contribute:
|
269
|
+
|
270
|
+
1. Fork the repository
|
271
|
+
2. Create a feature branch: `git checkout -b feature/your-feature-name`
|
272
|
+
3. Make your changes
|
273
|
+
4. Commit with clear messages following conventional commit guidelines
|
274
|
+
5. Push to your fork and submit a pull request
|
275
|
+
|
276
|
+
Please check the [CONTRIBUTING.md](CONTRIBUTING.md) file for detailed guidelines on code style, pull request process, and development setup.
|
277
|
+
|
245
278
|
## License
|
246
279
|
|
247
280
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
|
2
|
+
ngpt/cli.py,sha256=_nu7eY76_y4KQ59cKC91VijVvzSASAaSJI1FFfJ9l04,10655
|
3
|
+
ngpt/client.py,sha256=O0dPYeQCJlpWZWBBsroo-5UxeyBVwqC6o3Pm8lRnDiY,10329
|
4
|
+
ngpt/config.py,sha256=STnYKJor2nE_dKpK9NcnWlz3A8HeB8ufp-xOewGmRVo,5947
|
5
|
+
ngpt-1.1.4.dist-info/METADATA,sha256=kCn6kuMVbjmD0_LTjVyq1D_5MXrB6aNJpgF7Qf9QopE,9240
|
6
|
+
ngpt-1.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
ngpt-1.1.4.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
8
|
+
ngpt-1.1.4.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
9
|
+
ngpt-1.1.4.dist-info/RECORD,,
|
ngpt-1.1.3.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
ngpt/__init__.py,sha256=ehInP9w0MZlS1vZ1g6Cm4YE1ftmgF72CnEddQ3Le9n4,368
|
2
|
-
ngpt/cli.py,sha256=_nu7eY76_y4KQ59cKC91VijVvzSASAaSJI1FFfJ9l04,10655
|
3
|
-
ngpt/client.py,sha256=j7UCX_nkFRQJ_15ynxdu0Tj3HxxsI7Ll4__HdTbD7zE,10400
|
4
|
-
ngpt/config.py,sha256=JWCEp1aMq96i8owi4z_poKigaA_s2UTfzY0fjBM5MoQ,5295
|
5
|
-
ngpt-1.1.3.dist-info/METADATA,sha256=QTx1AssxeYEUlGOUpDdvssIVlvh2Xl8tqp9-a4wXwWs,8002
|
6
|
-
ngpt-1.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
ngpt-1.1.3.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
8
|
-
ngpt-1.1.3.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
9
|
-
ngpt-1.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|