ngpt 2.9.0__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_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 boolean options
117
- if option_type == "bool" and "exclusive" in CLI_CONFIG_OPTIONS[option]:
118
- if parsed_value: # If setting this option to True
119
- # Set all other exclusive options to False
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
- config[excl_option] = False
122
- # No special handling needed if setting to False, just update the value
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
ngpt/utils/__init__.py ADDED
@@ -0,0 +1 @@
1
+ # ngpt utils module
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.9.0
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
@@ -292,7 +292,9 @@ nGPT can also be used as a framework to build your own AI-powered command-line t
292
292
 
293
293
  ```python
294
294
  from ngpt import NGPTClient, load_config
295
- from ngpt.cli import interactive_chat_session, prettify_markdown, ColoredHelpFormatter
295
+ from ngpt.cli.main import interactive_chat_session
296
+ from ngpt.cli.renderers import prettify_markdown
297
+ from ngpt.cli.formatters import ColoredHelpFormatter
296
298
  import argparse
297
299
 
298
300
  # Create a custom CLI tool with colorized help
@@ -0,0 +1,23 @@
1
+ ngpt/__init__.py,sha256=awvycdj3tgcOr0BO81L4XU6DOtnToxFqkPHe1Pyu0Bw,652
2
+ ngpt/cli.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
3
+ ngpt/cli_config.py,sha256=Om8dXqdBqPCP5V4THQMkzZgHTQvN2rMAV6QjoVDQcZ4,10000
4
+ ngpt/client.py,sha256=Rv-JO8RAmw1v3gdLkwaPe_PEw6p83cejO0YNT_DDjeg,15134
5
+ ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
6
+ ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
7
+ ngpt/cli/config_manager.py,sha256=L091h99ntMBth_FM39npGCOtDCV5kVkukNSkCIj6dpI,3752
8
+ ngpt/cli/formatters.py,sha256=1ofNEWEZtFr0MJ3oWomoL_mFmZHlUdT3I5qGtbDQ4g0,9378
9
+ ngpt/cli/interactive.py,sha256=J6DFkJVBdJ6NjZllsDgJnY1J5RTiKW341p4Zn4wHpGc,11718
10
+ ngpt/cli/main.py,sha256=6VvBg-PSVY8pm9WiPNXkyPQuzX-dCPNrEX5UPIZWXYk,30711
11
+ ngpt/cli/renderers.py,sha256=U3Vef3nY1NF2JKtLUtUjdFomyqIrijGWdxRPm46urr4,10546
12
+ ngpt/cli/ui.py,sha256=2JXkCRw5utaKpNZIy0u8F_Jh2zrWbm93dMz91wf9CkQ,5334
13
+ ngpt/cli/modes/__init__.py,sha256=11znFpqzHyRsEtaTrms5M3q2SrscT9VvUgr7C2B1o-E,179
14
+ ngpt/cli/modes/chat.py,sha256=ilTEGu3a8FJ_wGC_P5WnDLx0Okzh3QxJ8HoiYj84g0o,2721
15
+ ngpt/cli/modes/code.py,sha256=_Z3cKYdeifYZSXZ4dMnQWcnVpM2TvYQd-7S7Q3blfEw,3998
16
+ ngpt/cli/modes/shell.py,sha256=Fx83_JBc3P5vgCCPlXgXFSgzwTY0UMGfUwY4_CU10Ro,1654
17
+ ngpt/cli/modes/text.py,sha256=YpNpcujPweO_Biwg4aYwGw4_ShefzaNVtf8d_QrcR_Q,2719
18
+ ngpt/utils/__init__.py,sha256=NK8wlI9-YeaKPOaXBVfUj3mKOXohfD3GmNy5obOIXOM,20
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,,
@@ -1,10 +0,0 @@
1
- ngpt/__init__.py,sha256=awvycdj3tgcOr0BO81L4XU6DOtnToxFqkPHe1Pyu0Bw,652
2
- ngpt/cli.py,sha256=8E65ovaJE0OJ3-M6aw_FqCNSy_1-x1h4NwhnsZOlXq4,81580
3
- ngpt/cli_config.py,sha256=LatikOJTtohbmCfXM6AH44qplbpyAD-x1kMkmaJHRS0,9046
4
- ngpt/client.py,sha256=Rv-JO8RAmw1v3gdLkwaPe_PEw6p83cejO0YNT_DDjeg,15134
5
- ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
6
- ngpt-2.9.0.dist-info/METADATA,sha256=mA32IXz-eKDqJBnXFjdOq9miHkQc2sDUBv78zw7sWec,20277
7
- ngpt-2.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- ngpt-2.9.0.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
9
- ngpt-2.9.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
10
- ngpt-2.9.0.dist-info/RECORD,,
File without changes