ngpt 2.11.0__py3-none-any.whl → 2.11.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/__init__.py CHANGED
@@ -2,8 +2,8 @@ from importlib.metadata import version as get_version
2
2
  __version__ = get_version("ngpt")
3
3
 
4
4
  from .client import NGPTClient
5
- from .config import load_config, get_config_path, get_config_dir
6
- from .cli_config import (
5
+ from .utils.config import load_config, get_config_path, get_config_dir
6
+ from .utils.cli_config import (
7
7
  load_cli_config,
8
8
  set_cli_config_option,
9
9
  get_cli_config_option,
@@ -1,5 +1,5 @@
1
1
  import sys
2
- from ..config import get_config_path, load_configs, add_config_entry, remove_config_entry
2
+ from ..utils.config import get_config_path, load_configs, add_config_entry, remove_config_entry
3
3
  from .formatters import COLORS
4
4
 
5
5
  def show_config_help():
ngpt/cli/interactive.py CHANGED
@@ -5,7 +5,7 @@ import datetime
5
5
  import traceback
6
6
  from .formatters import COLORS
7
7
  from .renderers import prettify_markdown, prettify_streaming_markdown
8
- from ..log import create_logger
8
+ from ..utils.log import create_logger
9
9
 
10
10
  # Optional imports for enhanced UI
11
11
  try:
ngpt/cli/main.py CHANGED
@@ -2,8 +2,8 @@ import argparse
2
2
  import sys
3
3
  import os
4
4
  from ..client import NGPTClient
5
- from ..config import load_config, get_config_path, load_configs, add_config_entry, remove_config_entry
6
- from ..cli_config import (
5
+ from ..utils.config import load_config, get_config_path, load_configs, add_config_entry, remove_config_entry
6
+ from ..utils.cli_config import (
7
7
  set_cli_config_option,
8
8
  get_cli_config_option,
9
9
  unset_cli_config_option,
@@ -12,7 +12,7 @@ from ..cli_config import (
12
12
  CLI_CONFIG_OPTIONS,
13
13
  load_cli_config
14
14
  )
15
- from ..log import create_logger
15
+ from ..utils.log import create_logger
16
16
  from .. import __version__
17
17
 
18
18
  from .formatters import COLORS, ColoredHelpFormatter
@@ -330,10 +330,20 @@ def main():
330
330
 
331
331
  return
332
332
 
333
- # Regular config addition/editing (existing code)
334
- # If --config-index was not explicitly specified, create a new entry by passing None
335
- # This will cause add_config_entry to create a new entry at the end of the list
336
- # Otherwise, edit the existing config at the specified index
333
+ # Check if --config-index was explicitly specified in command line args
334
+ config_index_explicit = '--config-index' in sys.argv
335
+ provider_explicit = '--provider' in sys.argv
336
+
337
+ # When only --config is used (without explicit --config-index or --provider),
338
+ # always create a new configuration regardless of CLI config settings
339
+ if not config_index_explicit and not provider_explicit:
340
+ # Always create a new config when just --config is used
341
+ configs = load_configs(str(config_path))
342
+ print(f"Creating new configuration at index {len(configs)}")
343
+ add_config_entry(config_path, None)
344
+ return
345
+
346
+ # If explicitly specified indexes or provider, continue with editing behavior
337
347
  config_index = None
338
348
 
339
349
  # Determine if we're editing an existing config or creating a new one
@@ -361,7 +371,7 @@ def main():
361
371
  config_index = matching_configs[0]
362
372
 
363
373
  print(f"Editing existing configuration at index {config_index}")
364
- elif effective_config_index != 0 or '--config-index' in sys.argv:
374
+ elif effective_config_index != 0 or config_index_explicit:
365
375
  # Check if the index is valid
366
376
  configs = load_configs(str(config_path))
367
377
  if effective_config_index >= 0 and effective_config_index < len(configs):
ngpt/cli/modes/chat.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from ..formatters import COLORS
2
2
  from ..renderers import prettify_markdown, prettify_streaming_markdown
3
- from ...log import create_logger
3
+ from ...utils.log import create_logger
4
4
  import sys
5
5
 
6
6
  def chat_mode(client, args, logger=None):
ngpt/cli/modes/code.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from ..formatters import COLORS
2
2
  from ..renderers import prettify_markdown, prettify_streaming_markdown, has_markdown_renderer, show_available_renderers
3
- from ...log import create_logger
3
+ from ...utils.log import create_logger
4
4
  import sys
5
5
 
6
6
  def code_mode(client, args, logger=None):
ngpt/cli/modes/shell.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from ..formatters import COLORS
2
- from ...log import create_logger
2
+ from ...utils.log import create_logger
3
3
  import subprocess
4
4
  import sys
5
5
 
ngpt/cli/modes/text.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from ..formatters import COLORS
2
2
  from ..renderers import prettify_markdown, prettify_streaming_markdown
3
3
  from ..ui import get_multiline_input
4
- from ...log import create_logger
4
+ from ...utils.log import create_logger
5
5
 
6
6
  def text_mode(client, args, logger=None):
7
7
  """Handle the multi-line text input mode.
ngpt/utils/__init__.py CHANGED
@@ -1 +1,33 @@
1
1
  # ngpt utils module
2
+
3
+ from .log import create_logger, Logger
4
+ from .config import (
5
+ load_config,
6
+ get_config_path,
7
+ get_config_dir,
8
+ load_configs,
9
+ add_config_entry,
10
+ remove_config_entry,
11
+ DEFAULT_CONFIG,
12
+ DEFAULT_CONFIG_ENTRY
13
+ )
14
+ from .cli_config import (
15
+ load_cli_config,
16
+ set_cli_config_option,
17
+ get_cli_config_option,
18
+ unset_cli_config_option,
19
+ apply_cli_config,
20
+ list_cli_config_options,
21
+ CLI_CONFIG_OPTIONS,
22
+ get_cli_config_dir,
23
+ get_cli_config_path
24
+ )
25
+
26
+ __all__ = [
27
+ "create_logger", "Logger",
28
+ "load_config", "get_config_path", "get_config_dir", "load_configs",
29
+ "add_config_entry", "remove_config_entry", "DEFAULT_CONFIG", "DEFAULT_CONFIG_ENTRY",
30
+ "load_cli_config", "set_cli_config_option", "get_cli_config_option",
31
+ "unset_cli_config_option", "apply_cli_config", "list_cli_config_options",
32
+ "CLI_CONFIG_OPTIONS", "get_cli_config_dir", "get_cli_config_path"
33
+ ]
@@ -212,7 +212,13 @@ def apply_cli_config(args: Any, mode: str) -> Any:
212
212
  # Keep track of applied exclusive options
213
213
  applied_exclusives = set()
214
214
 
215
- # For each option in CLI config, check if it should be applied
215
+ # First pass: Check explicitly set args and track their exclusive options
216
+ for option in CLI_CONFIG_OPTIONS:
217
+ cli_option = f"--{option}"
218
+ if cli_option in explicit_args and "exclusive" in CLI_CONFIG_OPTIONS[option]:
219
+ applied_exclusives.update(CLI_CONFIG_OPTIONS[option]["exclusive"])
220
+
221
+ # Second pass: Apply CLI config options
216
222
  for option, value in cli_config.items():
217
223
  # Skip if not a valid option
218
224
  if option not in CLI_CONFIG_OPTIONS:
@@ -227,12 +233,8 @@ def apply_cli_config(args: Any, mode: str) -> Any:
227
233
  arg_name = option.replace("-", "_")
228
234
 
229
235
  # Skip if explicitly set via command line
230
- # Check common variants like --option
231
236
  cli_option = f"--{option}"
232
237
  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
238
  continue
237
239
 
238
240
  # Skip if an exclusive option has already been applied
@@ -240,7 +242,6 @@ def apply_cli_config(args: Any, mode: str) -> Any:
240
242
  continue
241
243
 
242
244
  # Check exclusivity constraints against *explicitly set* args
243
- # Don't apply a CLI config option if an exclusive option was explicitly set
244
245
  if "exclusive" in CLI_CONFIG_OPTIONS[option]:
245
246
  skip = False
246
247
  for excl_option in CLI_CONFIG_OPTIONS[option]["exclusive"]:
@@ -250,14 +251,23 @@ def apply_cli_config(args: Any, mode: str) -> Any:
250
251
  break # Skip applying this CLI config value
251
252
  if skip:
252
253
  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"])
256
-
254
+
257
255
  # Apply the value from CLI config
258
256
  # Ensure the attribute exists on args before setting
259
257
  if hasattr(args, arg_name):
260
258
  setattr(args, arg_name, value)
259
+
260
+ # For boolean options that are True, explicitly disable their exclusive options
261
+ option_type = CLI_CONFIG_OPTIONS[option]["type"]
262
+ if option_type == "bool" and value is True and "exclusive" in CLI_CONFIG_OPTIONS[option]:
263
+ for excl_option in CLI_CONFIG_OPTIONS[option]["exclusive"]:
264
+ # Convert to argparse naming and set to False if the attribute exists
265
+ excl_arg_name = excl_option.replace("-", "_")
266
+ if hasattr(args, excl_arg_name):
267
+ setattr(args, excl_arg_name, False)
268
+
269
+ # Add exclusives to tracking set to prevent them from being applied
270
+ applied_exclusives.update(CLI_CONFIG_OPTIONS[option]["exclusive"])
261
271
 
262
272
  return args
263
273
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ngpt
3
- Version: 2.11.0
3
+ Version: 2.11.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
@@ -231,7 +231,8 @@ For more CLI examples and detailed usage information, see the [CLI Usage Guide](
231
231
  ### As a Library
232
232
 
233
233
  ```python
234
- from ngpt import NGPTClient, load_config
234
+ from ngpt import NGPTClient
235
+ from ngpt.utils.config import load_config
235
236
 
236
237
  # Load the first configuration (index 0) from config file
237
238
  config = load_config(config_index=0)
@@ -295,7 +296,8 @@ For advanced usage patterns and integrations, check out the [Advanced Examples](
295
296
  nGPT can also be used as a framework to build your own AI-powered command-line tools. You can leverage nGPT's pre-built CLI components to quickly develop sophisticated CLI applications.
296
297
 
297
298
  ```python
298
- from ngpt import NGPTClient, load_config
299
+ from ngpt import NGPTClient
300
+ from ngpt.utils.config import load_config
299
301
  from ngpt.cli.interactive import interactive_chat_session
300
302
  from ngpt.cli.renderers import prettify_markdown
301
303
  from ngpt.cli.args import setup_argument_parser
@@ -0,0 +1,25 @@
1
+ ngpt/__init__.py,sha256=kpKhViLakwMdHZkuLht2vWcjt0uD_5gR33gvMhfXr6w,664
2
+ ngpt/cli.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
3
+ ngpt/client.py,sha256=Rv-JO8RAmw1v3gdLkwaPe_PEw6p83cejO0YNT_DDjeg,15134
4
+ ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
5
+ ngpt/cli/args.py,sha256=2e13wYQGfHFXpxZz5wXuvmoYpIkK6PEZQamHxfHAdyY,8868
6
+ ngpt/cli/config_manager.py,sha256=POjX3Asqap2N_Y6Qq0JC3OLZdzxRpFz3D0Lk19Now2U,3758
7
+ ngpt/cli/formatters.py,sha256=1ofNEWEZtFr0MJ3oWomoL_mFmZHlUdT3I5qGtbDQ4g0,9378
8
+ ngpt/cli/interactive.py,sha256=5xMMP1MuYW4jsbUEbjElE25fcJpgHVBbx2dIj8M39M8,10959
9
+ ngpt/cli/main.py,sha256=wSFVkg42NYIJQLMI9iOkW9nz2c6uukmwZghbaw6fYDk,27533
10
+ ngpt/cli/renderers.py,sha256=U3Vef3nY1NF2JKtLUtUjdFomyqIrijGWdxRPm46urr4,10546
11
+ ngpt/cli/ui.py,sha256=2JXkCRw5utaKpNZIy0u8F_Jh2zrWbm93dMz91wf9CkQ,5334
12
+ ngpt/cli/modes/__init__.py,sha256=11znFpqzHyRsEtaTrms5M3q2SrscT9VvUgr7C2B1o-E,179
13
+ ngpt/cli/modes/chat.py,sha256=OtD0iNoSpJ79gojaaCDOr0WPpRmAwzPPG8kwDjESrXo,3177
14
+ ngpt/cli/modes/code.py,sha256=bFE6x_CUncOM0gyAHOpcJs6nxj_ljFK0AYwJiT1Ndaw,4332
15
+ ngpt/cli/modes/shell.py,sha256=oqqEqWdqcH5q4pmis-hT9ZEFNk9-kaKHHdpRu217u5A,2721
16
+ ngpt/cli/modes/text.py,sha256=sUhgE5XubYxksnQDUvnCFrEbqz1G-CS_iWZZMGkULcI,3179
17
+ ngpt/utils/__init__.py,sha256=E46suk2-QgYBI0Qrs6WXOajOUOebF3ETAFY7ah8DTWs,942
18
+ ngpt/utils/cli_config.py,sha256=_epz6MzSBOiE6cMkQDggkzfRRV5gga4eg-2UW955GrM,10545
19
+ ngpt/utils/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
20
+ ngpt/utils/log.py,sha256=Bxv2-GbWtVYa3u94Zs_OVEvYk_CbuT5hrDH06KHLXa8,6369
21
+ ngpt-2.11.2.dist-info/METADATA,sha256=XpjOCWolqeW9YKDL_VQCITLYcDxedgDCQCrxnzlcLr4,20627
22
+ ngpt-2.11.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
+ ngpt-2.11.2.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
24
+ ngpt-2.11.2.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
25
+ ngpt-2.11.2.dist-info/RECORD,,
@@ -1,25 +0,0 @@
1
- ngpt/__init__.py,sha256=awvycdj3tgcOr0BO81L4XU6DOtnToxFqkPHe1Pyu0Bw,652
2
- ngpt/cli.py,sha256=j3eFYPOtCCFBOGh7NK5IWEnADnTMMSEB9GLyIDoW724,66
3
- ngpt/cli_config.py,sha256=fUtahEUJlFt1cguIXrfHk0exn6O1qnm50uTKAgvtySc,9984
4
- ngpt/client.py,sha256=Rv-JO8RAmw1v3gdLkwaPe_PEw6p83cejO0YNT_DDjeg,15134
5
- ngpt/config.py,sha256=WYOk_b1eiYjo6hpV3pfXr2RjqhOnmKqwZwKid1T41I4,10363
6
- ngpt/log.py,sha256=Bxv2-GbWtVYa3u94Zs_OVEvYk_CbuT5hrDH06KHLXa8,6369
7
- ngpt/cli/__init__.py,sha256=hebbDSMGiOd43YNnQP67uzr67Ue6rZPwm2czynr5iZY,43
8
- ngpt/cli/args.py,sha256=2e13wYQGfHFXpxZz5wXuvmoYpIkK6PEZQamHxfHAdyY,8868
9
- ngpt/cli/config_manager.py,sha256=L091h99ntMBth_FM39npGCOtDCV5kVkukNSkCIj6dpI,3752
10
- ngpt/cli/formatters.py,sha256=1ofNEWEZtFr0MJ3oWomoL_mFmZHlUdT3I5qGtbDQ4g0,9378
11
- ngpt/cli/interactive.py,sha256=8TBDbAqgenu8JiIJzVEGN67bcDA71WKJBXmBhdcJl-E,10953
12
- ngpt/cli/main.py,sha256=N2vCeVKDGJFIkVVPxGYgE2wCq6n0vAhdIE3dil7Mqv4,27043
13
- ngpt/cli/renderers.py,sha256=U3Vef3nY1NF2JKtLUtUjdFomyqIrijGWdxRPm46urr4,10546
14
- ngpt/cli/ui.py,sha256=2JXkCRw5utaKpNZIy0u8F_Jh2zrWbm93dMz91wf9CkQ,5334
15
- ngpt/cli/modes/__init__.py,sha256=11znFpqzHyRsEtaTrms5M3q2SrscT9VvUgr7C2B1o-E,179
16
- ngpt/cli/modes/chat.py,sha256=dUyPG4wzUZYbCzfjXHpJvIocqbHMKSJuOMBNaJTAdsY,3171
17
- ngpt/cli/modes/code.py,sha256=o-dwPwom7cS6wwS1jlEzDoYwhwgh_ClwJYCFGvZw9es,4326
18
- ngpt/cli/modes/shell.py,sha256=zjfajH4BH2y18AzBlwvcryeke6hiS43rqPidNfJLKwQ,2715
19
- ngpt/cli/modes/text.py,sha256=QQr9dENJP35Xe8Ck0nbmD8gE7uVng4KEHcZkSHcQXCg,3173
20
- ngpt/utils/__init__.py,sha256=NK8wlI9-YeaKPOaXBVfUj3mKOXohfD3GmNy5obOIXOM,20
21
- ngpt-2.11.0.dist-info/METADATA,sha256=o9WAF9lC8DEqzJbP0_u1lz5qZLEPow6mzUSqPHKy6eY,20569
22
- ngpt-2.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- ngpt-2.11.0.dist-info/entry_points.txt,sha256=1cnAMujyy34DlOahrJg19lePSnb08bLbkUs_kVerqdk,39
24
- ngpt-2.11.0.dist-info/licenses/LICENSE,sha256=mQkpWoADxbHqE0HRefYLJdm7OpdrXBr3vNv5bZ8w72M,1065
25
- ngpt-2.11.0.dist-info/RECORD,,
File without changes
File without changes
File without changes