ngpt 2.9.1__py3-none-any.whl → 2.9.2__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/cli/main.py +12 -2
- ngpt/cli_config.py +27 -8
- {ngpt-2.9.1.dist-info → ngpt-2.9.2.dist-info}/METADATA +1 -1
- {ngpt-2.9.1.dist-info → ngpt-2.9.2.dist-info}/RECORD +7 -7
- {ngpt-2.9.1.dist-info → ngpt-2.9.2.dist-info}/WHEEL +0 -0
- {ngpt-2.9.1.dist-info → ngpt-2.9.2.dist-info}/entry_points.txt +0 -0
- {ngpt-2.9.1.dist-info → ngpt-2.9.2.dist-info}/licenses/LICENSE +0 -0
ngpt/cli/main.py
CHANGED
@@ -27,6 +27,7 @@ def show_cli_config_help():
|
|
27
27
|
"""Display help information about CLI configuration."""
|
28
28
|
print(f"\n{COLORS['green']}{COLORS['bold']}CLI Configuration Help:{COLORS['reset']}")
|
29
29
|
print(f" {COLORS['cyan']}Command syntax:{COLORS['reset']}")
|
30
|
+
print(f" {COLORS['yellow']}ngpt --cli-config help{COLORS['reset']} - Show this help message")
|
30
31
|
print(f" {COLORS['yellow']}ngpt --cli-config set OPTION VALUE{COLORS['reset']} - Set a default value for OPTION")
|
31
32
|
print(f" {COLORS['yellow']}ngpt --cli-config get OPTION{COLORS['reset']} - Get the current value of OPTION")
|
32
33
|
print(f" {COLORS['yellow']}ngpt --cli-config get{COLORS['reset']} - Show all CLI configuration settings")
|
@@ -83,16 +84,25 @@ def show_cli_config_help():
|
|
83
84
|
print(f" {COLORS['yellow']}ngpt --cli-config set language java{COLORS['reset']} - Set default language to java for code generation")
|
84
85
|
print(f" {COLORS['yellow']}ngpt --cli-config set temperature 0.9{COLORS['reset']} - Set default temperature to 0.9")
|
85
86
|
print(f" {COLORS['yellow']}ngpt --cli-config set no-stream true{COLORS['reset']} - Disable streaming by default")
|
87
|
+
print(f" {COLORS['yellow']}ngpt --cli-config get temperature{COLORS['reset']} - Check the current temperature setting")
|
88
|
+
print(f" {COLORS['yellow']}ngpt --cli-config get{COLORS['reset']} - Show all current CLI settings")
|
86
89
|
print(f" {COLORS['yellow']}ngpt --cli-config unset language{COLORS['reset']} - Remove language setting")
|
87
90
|
|
88
91
|
print(f"\n {COLORS['cyan']}Notes:{COLORS['reset']}")
|
89
|
-
print(f" - CLI configuration is stored in
|
92
|
+
print(f" - CLI configuration is stored in:")
|
93
|
+
print(f" • Linux: {COLORS['yellow']}~/.config/ngpt/ngpt-cli.conf{COLORS['reset']}")
|
94
|
+
print(f" • macOS: {COLORS['yellow']}~/Library/Application Support/ngpt/ngpt-cli.conf{COLORS['reset']}")
|
95
|
+
print(f" • Windows: {COLORS['yellow']}%APPDATA%\\ngpt\\ngpt-cli.conf{COLORS['reset']}")
|
90
96
|
print(f" - Settings are applied based on context (e.g., language only applies to code generation mode)")
|
91
97
|
print(f" - Command-line arguments always override CLI configuration")
|
92
98
|
print(f" - Some options are mutually exclusive and will not be applied together")
|
93
99
|
|
94
100
|
def handle_cli_config(action, option=None, value=None):
|
95
101
|
"""Handle CLI configuration commands."""
|
102
|
+
if action == "help":
|
103
|
+
show_cli_config_help()
|
104
|
+
return
|
105
|
+
|
96
106
|
if action == "list":
|
97
107
|
# List all available options
|
98
108
|
print(f"{COLORS['green']}{COLORS['bold']}Available CLI configuration options:{COLORS['reset']}")
|
@@ -254,7 +264,7 @@ def main():
|
|
254
264
|
option = args.cli_config[1] if len(args.cli_config) > 1 else None
|
255
265
|
value = args.cli_config[2] if len(args.cli_config) > 2 else None
|
256
266
|
|
257
|
-
if action in ("set", "get", "unset", "list"):
|
267
|
+
if action in ("set", "get", "unset", "list", "help"):
|
258
268
|
handle_cli_config(action, option, value)
|
259
269
|
return
|
260
270
|
else:
|
ngpt/cli_config.py
CHANGED
@@ -7,7 +7,7 @@ from typing import Dict, Optional, Any, List, Union, Tuple
|
|
7
7
|
# CLI config options with their types and default values
|
8
8
|
CLI_CONFIG_OPTIONS = {
|
9
9
|
"language": {"type": "str", "default": "python", "context": ["code"]},
|
10
|
-
"provider": {"type": "str", "default": None, "context": ["all"]},
|
10
|
+
"provider": {"type": "str", "default": None, "context": ["all"], "exclusive": ["config-index"]},
|
11
11
|
"temperature": {"type": "float", "default": 0.7, "context": ["all"]},
|
12
12
|
"top_p": {"type": "float", "default": 1.0, "context": ["all"]},
|
13
13
|
"max_tokens": {"type": "int", "default": None, "context": ["all"]},
|
@@ -17,7 +17,7 @@ CLI_CONFIG_OPTIONS = {
|
|
17
17
|
"prettify": {"type": "bool", "default": False, "context": ["all"], "exclusive": ["no-stream", "stream-prettify"]},
|
18
18
|
"stream-prettify": {"type": "bool", "default": False, "context": ["all"], "exclusive": ["no-stream", "prettify"]},
|
19
19
|
"renderer": {"type": "str", "default": "auto", "context": ["all"]},
|
20
|
-
"config-index": {"type": "int", "default": 0, "context": ["all"]},
|
20
|
+
"config-index": {"type": "int", "default": 0, "context": ["all"], "exclusive": ["provider"]},
|
21
21
|
"web-search": {"type": "bool", "default": False, "context": ["all"]},
|
22
22
|
}
|
23
23
|
|
@@ -113,13 +113,19 @@ def set_cli_config_option(option: str, value: Any) -> Tuple[bool, str]:
|
|
113
113
|
else:
|
114
114
|
return False, f"Error: Unsupported option type '{option_type}'"
|
115
115
|
|
116
|
-
# Handle mutual exclusivity for
|
117
|
-
if
|
118
|
-
if
|
119
|
-
#
|
116
|
+
# Handle mutual exclusivity for options
|
117
|
+
if "exclusive" in CLI_CONFIG_OPTIONS[option]:
|
118
|
+
if option_type == "bool":
|
119
|
+
# For boolean options: only apply exclusivity when setting to True
|
120
|
+
if parsed_value:
|
121
|
+
for excl_option in CLI_CONFIG_OPTIONS[option]["exclusive"]:
|
122
|
+
config[excl_option] = False
|
123
|
+
# If setting to False, don't alter exclusive options
|
124
|
+
else:
|
125
|
+
# For non-boolean options: If setting this option to any value, remove exclusive options
|
120
126
|
for excl_option in CLI_CONFIG_OPTIONS[option]["exclusive"]:
|
121
|
-
|
122
|
-
|
127
|
+
if excl_option in config:
|
128
|
+
del config[excl_option]
|
123
129
|
|
124
130
|
# Set the value in the config
|
125
131
|
config[option] = parsed_value
|
@@ -203,6 +209,9 @@ def apply_cli_config(args: Any, mode: str) -> Any:
|
|
203
209
|
# Get command-line arguments provided by the user
|
204
210
|
explicit_args = set(arg for arg in sys.argv[1:] if arg.startswith('--'))
|
205
211
|
|
212
|
+
# Keep track of applied exclusive options
|
213
|
+
applied_exclusives = set()
|
214
|
+
|
206
215
|
# For each option in CLI config, check if it should be applied
|
207
216
|
for option, value in cli_config.items():
|
208
217
|
# Skip if not a valid option
|
@@ -221,6 +230,13 @@ def apply_cli_config(args: Any, mode: str) -> Any:
|
|
221
230
|
# Check common variants like --option
|
222
231
|
cli_option = f"--{option}"
|
223
232
|
if cli_option in explicit_args:
|
233
|
+
# Add to applied_exclusives if this option has exclusivity constraints
|
234
|
+
if "exclusive" in CLI_CONFIG_OPTIONS[option]:
|
235
|
+
applied_exclusives.update(CLI_CONFIG_OPTIONS[option]["exclusive"])
|
236
|
+
continue
|
237
|
+
|
238
|
+
# Skip if an exclusive option has already been applied
|
239
|
+
if option in applied_exclusives:
|
224
240
|
continue
|
225
241
|
|
226
242
|
# Check exclusivity constraints against *explicitly set* args
|
@@ -234,6 +250,9 @@ def apply_cli_config(args: Any, mode: str) -> Any:
|
|
234
250
|
break # Skip applying this CLI config value
|
235
251
|
if skip:
|
236
252
|
continue
|
253
|
+
|
254
|
+
# If we're applying this option, add its exclusives to the tracking set
|
255
|
+
applied_exclusives.update(CLI_CONFIG_OPTIONS[option]["exclusive"])
|
237
256
|
|
238
257
|
# Apply the value from CLI config
|
239
258
|
# Ensure the attribute exists on args before setting
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ngpt
|
3
|
-
Version: 2.9.
|
3
|
+
Version: 2.9.2
|
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
|
@@ -1,13 +1,13 @@
|
|
1
1
|
ngpt/__init__.py,sha256=awvycdj3tgcOr0BO81L4XU6DOtnToxFqkPHe1Pyu0Bw,652
|
2
2
|
ngpt/cli.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
|
3
|
-
ngpt/cli_config.py,sha256=
|
3
|
+
ngpt/cli_config.py,sha256=Om8dXqdBqPCP5V4THQMkzZgHTQvN2rMAV6QjoVDQcZ4,10000
|
4
4
|
ngpt/client.py,sha256=Rv-JO8RAmw1v3gdLkwaPe_PEw6p83cejO0YNT_DDjeg,15134
|
5
5
|
ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
|
6
6
|
ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
|
7
7
|
ngpt/cli/config_manager.py,sha256=L091h99ntMBth_FM39npGCOtDCV5kVkukNSkCIj6dpI,3752
|
8
8
|
ngpt/cli/formatters.py,sha256=1ofNEWEZtFr0MJ3oWomoL_mFmZHlUdT3I5qGtbDQ4g0,9378
|
9
9
|
ngpt/cli/interactive.py,sha256=J6DFkJVBdJ6NjZllsDgJnY1J5RTiKW341p4Zn4wHpGc,11718
|
10
|
-
ngpt/cli/main.py,sha256=
|
10
|
+
ngpt/cli/main.py,sha256=6VvBg-PSVY8pm9WiPNXkyPQuzX-dCPNrEX5UPIZWXYk,30711
|
11
11
|
ngpt/cli/renderers.py,sha256=U3Vef3nY1NF2JKtLUtUjdFomyqIrijGWdxRPm46urr4,10546
|
12
12
|
ngpt/cli/ui.py,sha256=2JXkCRw5utaKpNZIy0u8F_Jh2zrWbm93dMz91wf9CkQ,5334
|
13
13
|
ngpt/cli/modes/__init__.py,sha256=11znFpqzHyRsEtaTrms5M3q2SrscT9VvUgr7C2B1o-E,179
|
@@ -16,8 +16,8 @@ ngpt/cli/modes/code.py,sha256=_Z3cKYdeifYZSXZ4dMnQWcnVpM2TvYQd-7S7Q3blfEw,3998
|
|
16
16
|
ngpt/cli/modes/shell.py,sha256=Fx83_JBc3P5vgCCPlXgXFSgzwTY0UMGfUwY4_CU10Ro,1654
|
17
17
|
ngpt/cli/modes/text.py,sha256=YpNpcujPweO_Biwg4aYwGw4_ShefzaNVtf8d_QrcR_Q,2719
|
18
18
|
ngpt/utils/__init__.py,sha256=NK8wlI9-YeaKPOaXBVfUj3mKOXohfD3GmNy5obOIXOM,20
|
19
|
-
ngpt-2.9.
|
20
|
-
ngpt-2.9.
|
21
|
-
ngpt-2.9.
|
22
|
-
ngpt-2.9.
|
23
|
-
ngpt-2.9.
|
19
|
+
ngpt-2.9.2.dist-info/METADATA,sha256=Re9hYNXfjtWAu4HIl220MSiRa2Ckgq2hTiDr3lPdZis,20343
|
20
|
+
ngpt-2.9.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
21
|
+
ngpt-2.9.2.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
|
22
|
+
ngpt-2.9.2.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
|
23
|
+
ngpt-2.9.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|