pygpt-net 2.6.60__py3-none-any.whl → 2.6.62__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.
Files changed (87) hide show
  1. pygpt_net/CHANGELOG.txt +14 -0
  2. pygpt_net/__init__.py +3 -3
  3. pygpt_net/controller/chat/common.py +115 -6
  4. pygpt_net/controller/chat/input.py +4 -1
  5. pygpt_net/controller/chat/response.py +8 -2
  6. pygpt_net/controller/presets/presets.py +121 -6
  7. pygpt_net/controller/settings/editor.py +0 -15
  8. pygpt_net/controller/settings/profile.py +16 -4
  9. pygpt_net/controller/settings/workdir.py +30 -5
  10. pygpt_net/controller/theme/common.py +4 -2
  11. pygpt_net/controller/theme/markdown.py +4 -7
  12. pygpt_net/controller/theme/theme.py +2 -1
  13. pygpt_net/controller/ui/ui.py +32 -7
  14. pygpt_net/core/agents/custom/__init__.py +7 -1
  15. pygpt_net/core/agents/custom/llama_index/factory.py +17 -6
  16. pygpt_net/core/agents/custom/llama_index/runner.py +52 -4
  17. pygpt_net/core/agents/custom/llama_index/utils.py +12 -1
  18. pygpt_net/core/agents/custom/router.py +45 -6
  19. pygpt_net/core/agents/custom/runner.py +11 -5
  20. pygpt_net/core/agents/custom/schema.py +3 -1
  21. pygpt_net/core/agents/custom/utils.py +13 -1
  22. pygpt_net/core/agents/runners/llama_workflow.py +65 -5
  23. pygpt_net/core/agents/runners/openai_workflow.py +2 -1
  24. pygpt_net/core/db/viewer.py +11 -5
  25. pygpt_net/core/node_editor/graph.py +18 -9
  26. pygpt_net/core/node_editor/models.py +9 -2
  27. pygpt_net/core/node_editor/types.py +15 -1
  28. pygpt_net/core/presets/presets.py +216 -29
  29. pygpt_net/core/render/markdown/parser.py +0 -2
  30. pygpt_net/core/render/web/renderer.py +76 -11
  31. pygpt_net/data/config/config.json +5 -6
  32. pygpt_net/data/config/models.json +3 -3
  33. pygpt_net/data/config/settings.json +2 -38
  34. pygpt_net/data/css/style.dark.css +18 -0
  35. pygpt_net/data/css/style.light.css +20 -1
  36. pygpt_net/data/locale/locale.de.ini +66 -1
  37. pygpt_net/data/locale/locale.en.ini +64 -3
  38. pygpt_net/data/locale/locale.es.ini +66 -1
  39. pygpt_net/data/locale/locale.fr.ini +66 -1
  40. pygpt_net/data/locale/locale.it.ini +66 -1
  41. pygpt_net/data/locale/locale.pl.ini +67 -2
  42. pygpt_net/data/locale/locale.uk.ini +66 -1
  43. pygpt_net/data/locale/locale.zh.ini +66 -1
  44. pygpt_net/data/locale/plugin.cmd_system.en.ini +62 -66
  45. pygpt_net/item/ctx.py +23 -1
  46. pygpt_net/provider/agents/llama_index/flow_from_schema.py +2 -2
  47. pygpt_net/provider/agents/llama_index/workflow/codeact.py +9 -6
  48. pygpt_net/provider/agents/llama_index/workflow/openai.py +38 -11
  49. pygpt_net/provider/agents/llama_index/workflow/planner.py +36 -16
  50. pygpt_net/provider/agents/llama_index/workflow/supervisor.py +60 -10
  51. pygpt_net/provider/agents/openai/agent.py +3 -1
  52. pygpt_net/provider/agents/openai/agent_b2b.py +13 -9
  53. pygpt_net/provider/agents/openai/agent_planner.py +6 -2
  54. pygpt_net/provider/agents/openai/agent_with_experts.py +4 -1
  55. pygpt_net/provider/agents/openai/agent_with_experts_feedback.py +4 -2
  56. pygpt_net/provider/agents/openai/agent_with_feedback.py +4 -2
  57. pygpt_net/provider/agents/openai/evolve.py +6 -2
  58. pygpt_net/provider/agents/openai/supervisor.py +3 -1
  59. pygpt_net/provider/api/openai/agents/response.py +1 -0
  60. pygpt_net/provider/core/config/patch.py +18 -1
  61. pygpt_net/provider/core/config/patches/patch_before_2_6_42.py +0 -6
  62. pygpt_net/tools/agent_builder/tool.py +48 -26
  63. pygpt_net/tools/agent_builder/ui/dialogs.py +36 -28
  64. pygpt_net/ui/__init__.py +2 -4
  65. pygpt_net/ui/dialog/about.py +58 -38
  66. pygpt_net/ui/dialog/db.py +142 -3
  67. pygpt_net/ui/dialog/preset.py +47 -8
  68. pygpt_net/ui/layout/toolbox/presets.py +64 -16
  69. pygpt_net/ui/main.py +2 -2
  70. pygpt_net/ui/widget/dialog/confirm.py +27 -3
  71. pygpt_net/ui/widget/dialog/db.py +0 -0
  72. pygpt_net/ui/widget/draw/painter.py +90 -1
  73. pygpt_net/ui/widget/lists/preset.py +908 -60
  74. pygpt_net/ui/widget/node_editor/command.py +10 -10
  75. pygpt_net/ui/widget/node_editor/config.py +157 -0
  76. pygpt_net/ui/widget/node_editor/editor.py +223 -153
  77. pygpt_net/ui/widget/node_editor/item.py +12 -11
  78. pygpt_net/ui/widget/node_editor/node.py +246 -13
  79. pygpt_net/ui/widget/node_editor/view.py +179 -63
  80. pygpt_net/ui/widget/tabs/output.py +1 -1
  81. pygpt_net/ui/widget/textarea/input.py +157 -23
  82. pygpt_net/utils.py +114 -2
  83. {pygpt_net-2.6.60.dist-info → pygpt_net-2.6.62.dist-info}/METADATA +26 -100
  84. {pygpt_net-2.6.60.dist-info → pygpt_net-2.6.62.dist-info}/RECORD +86 -85
  85. {pygpt_net-2.6.60.dist-info → pygpt_net-2.6.62.dist-info}/LICENSE +0 -0
  86. {pygpt_net-2.6.60.dist-info → pygpt_net-2.6.62.dist-info}/WHEEL +0 -0
  87. {pygpt_net-2.6.60.dist-info → pygpt_net-2.6.62.dist-info}/entry_points.txt +0 -0
pygpt_net/utils.py CHANGED
@@ -6,15 +6,19 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2025.08.19 07:00:00 #
9
+ # Updated Date: 2025.09.25 12:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
13
13
  import os
14
14
  import re
15
+ import math
16
+
15
17
  from datetime import datetime
16
18
  from contextlib import contextmanager
17
19
  from typing import Any
20
+ from decimal import Decimal, ROUND_HALF_UP, InvalidOperation
21
+ from typing import Sequence
18
22
 
19
23
  from PySide6 import QtCore, QtGui
20
24
  from PySide6.QtWidgets import QApplication
@@ -381,4 +385,112 @@ def mem_clean(force: bool = False) -> bool:
381
385
  '''
382
386
  except Exception as e:
383
387
  print(e)
384
- return ok
388
+ return ok
389
+
390
+ def short_num(value,
391
+ *,
392
+ base: int = 1000,
393
+ suffixes: Sequence[str] = ("", "k", "M", "B", "T", "P", "E"),
394
+ max_decimals: int = 1,
395
+ decimal_sep: str = ",") -> str:
396
+ """
397
+ Compact human-readable formatter for numbers with suffixes (k, M, B, ...).
398
+
399
+ Rules:
400
+ - abs(value) < base -> return the value without a suffix
401
+ - otherwise -> divide by base^n and append suffix
402
+ - decimals:
403
+ < 10 -> up to 2 (bounded by max_decimals)
404
+ < 100 -> up to 1 (bounded by max_decimals)
405
+ >= 100 -> 0
406
+ - rounding: ROUND_HALF_UP
407
+ - auto "carry" to the next suffix after rounding (e.g., 999.95k -> 1M)
408
+
409
+ Params:
410
+ - base: 1000 for general numbers, 1024 for bytes, etc.
411
+ - suffixes: first item must be "" (for < base)
412
+ - max_decimals: upper bound for fractional digits
413
+ - decimal_sep: decimal separator in the output
414
+ """
415
+
416
+ # --- helpers hidden inside (closure) ---
417
+
418
+ def _to_decimal(v) -> Decimal:
419
+ """Convert supported inputs to Decimal; keep NaN/Inf as-is."""
420
+ if isinstance(v, Decimal):
421
+ return v
422
+ if isinstance(v, int):
423
+ return Decimal(v)
424
+ if isinstance(v, float):
425
+ if math.isnan(v):
426
+ return Decimal("NaN")
427
+ if math.isinf(v):
428
+ return Decimal("Infinity") if v > 0 else Decimal("-Infinity")
429
+ # str() to avoid binary float artefacts
430
+ return Decimal(str(v))
431
+ try:
432
+ return Decimal(str(v))
433
+ except (InvalidOperation, ValueError, TypeError):
434
+ raise TypeError("short_num(value): value must be numeric (int/float/Decimal) "
435
+ "or a string parsable to a number.")
436
+
437
+ def _decimals_for(scaled: Decimal) -> int:
438
+ """Pick number of decimals based on magnitude."""
439
+ if max_decimals <= 0:
440
+ return 0
441
+ if scaled < 10:
442
+ return min(2, max_decimals)
443
+ if scaled < 100:
444
+ return min(1, max_decimals)
445
+ return 0
446
+
447
+ def _round_dec(d: Decimal, decimals: int) -> Decimal:
448
+ """ROUND_HALF_UP to the requested decimals."""
449
+ if decimals <= 0:
450
+ return d.quantize(Decimal("1"), rounding=ROUND_HALF_UP)
451
+ q = Decimal(1).scaleb(-decimals) # 10**(-decimals)
452
+ return d.quantize(q, rounding=ROUND_HALF_UP)
453
+
454
+ def _strip_trailing_zeros(s: str) -> str:
455
+ """Remove trailing zeros and trailing decimal point if needed."""
456
+ if "." in s:
457
+ s = s.rstrip("0").rstrip(".")
458
+ return s
459
+
460
+ # --- main logic ---
461
+
462
+ d = _to_decimal(value)
463
+ if not d.is_finite():
464
+ # For NaN/Inf just echo back Python-ish text
465
+ return str(value)
466
+
467
+ sign = "-" if d < 0 else ""
468
+ d = abs(d)
469
+
470
+ # For values below base, return "as is" (normalized, no suffix)
471
+ if d < base:
472
+ s = _strip_trailing_zeros(f"{d.normalize():f}")
473
+ return (sign + s).replace(".", decimal_sep)
474
+
475
+ # Find initial suffix tier
476
+ idx = 0
477
+ last_idx = len(suffixes) - 1
478
+ while d >= base and idx < last_idx:
479
+ d = d / base
480
+ idx += 1
481
+
482
+ # Choose decimals, round, then handle possible carry to next suffix
483
+ decimals = _decimals_for(d)
484
+ d = _round_dec(d, decimals)
485
+
486
+ while d >= base and idx < last_idx:
487
+ # Carry over (e.g., 999.95k -> 1000.00k -> 1.00M)
488
+ d = d / base
489
+ idx += 1
490
+ decimals = _decimals_for(d)
491
+ d = _round_dec(d, decimals)
492
+
493
+ # Format, trim zeros, apply custom decimal separator, attach suffix
494
+ out = f"{d:.{decimals}f}"
495
+ out = _strip_trailing_zeros(out).replace(".", decimal_sep)
496
+ return f"{sign}{out}{suffixes[idx]}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygpt-net
3
- Version: 2.6.60
3
+ Version: 2.6.62
4
4
  Summary: Desktop AI Assistant powered by: OpenAI GPT-5, GPT-4, o1, o3, Gemini, Claude, Grok, DeepSeek, and other models supported by Llama Index, and Ollama. Chatbot, agents, completion, image generation, vision analysis, speech-to-text, plugins, MCP, internet access, file handling, command execution and more.
5
5
  License: MIT
6
6
  Keywords: ai,api,api key,app,assistant,bielik,chat,chatbot,chatgpt,claude,dall-e,deepseek,desktop,gemini,gpt,gpt-3.5,gpt-4,gpt-4-vision,gpt-4o,gpt-5,gpt-oss,gpt3.5,gpt4,grok,langchain,llama-index,llama3,mistral,o1,o3,ollama,openai,presets,py-gpt,py_gpt,pygpt,pyside,qt,text completion,tts,ui,vision,whisper
@@ -117,7 +117,7 @@ Description-Content-Type: text/markdown
117
117
 
118
118
  [![pygpt](https://snapcraft.io/pygpt/badge.svg)](https://snapcraft.io/pygpt)
119
119
 
120
- Release: **2.6.60** | build: **2025-09-25** | Python: **>=3.10, <3.14**
120
+ Release: **2.6.62** | build: **2025-09-26** | Python: **>=3.10, <3.14**
121
121
 
122
122
  > Official website: https://pygpt.net | Documentation: https://pygpt.readthedocs.io
123
123
  >
@@ -787,6 +787,8 @@ Includes built-in agents (Legacy):
787
787
 
788
788
  In the future, the list of built-in agents will be expanded.
789
789
 
790
+ You can create your own types (workflows/patterns) using the built-in visual node-based editor found in the `Tools -> Agents Builder`.
791
+
790
792
  You can also create your own agent by creating a new provider that inherits from `pygpt_net.provider.agents.base`.
791
793
 
792
794
  **Tools and Plugins**
@@ -824,7 +826,7 @@ It allows running agents for OpenAI models and models compatible with the OpenAI
824
826
 
825
827
  In this mode, you can use pre-configured Experts in Expert mode presets - they will be launched as agents (in the `openai_agents_experts` type, which allows launching one main agent and subordinate agents to which queries will be appropriately directed).
826
828
 
827
- **Agent types:**
829
+ **Agent types (workflows/patterns):**
828
830
 
829
831
  - `Agent with experts` - uses attached experts as sub-agents
830
832
  - `Agent with experts + feedback` - uses attached experts as sub-agents + feedback agent in a loop
@@ -836,7 +838,7 @@ In this mode, you can use pre-configured Experts in Expert mode presets - they w
836
838
  - `B2B` - bot-to-bot communication, involving two bots interacting with each other while keeping a human in the loop.
837
839
  - `Supervisor + Worker` - one agent (supervisor) acts as a bridge between the user and the second agent (worker). The user provides a query to the supervisor, who then sends instructions to the worker until the task is completed by the worker.
838
840
 
839
- More types will be available in the future.
841
+ You can create your own types (workflows/patterns) using the built-in visual node-based editor found in the `Tools -> Agents Builder`.
840
842
 
841
843
  There are also predefined presets added as examples:
842
844
 
@@ -2181,10 +2183,10 @@ To add a new element, right-click on the editor grid and select `Add` to insert
2181
2183
 
2182
2184
  **Types of Nodes:**
2183
2185
 
2184
- - **Flow/Start**: The starting point for agents (user input).
2185
- - **Flow/Agent**: A single agent with customizable default parameters, such as system instructions and tool usage. These settings can be overridden in the preset.
2186
- - **Flow/Memory**: Shared memory between agents (shared Context).
2187
- - **Flow/End**: The endpoint, returning control to the user.
2186
+ - **Start**: The starting point for agents (user input).
2187
+ - **Agent**: A single agent with customizable default parameters, such as system instructions and tool usage. These settings can be overridden in the preset.
2188
+ - **Memory**: Shared memory between agents (shared Context).
2189
+ - **End**: The endpoint, returning control to the user.
2188
2190
 
2189
2191
  Agents with connected shared memory share it among themselves. Agents without shared memory only receive the latest output from the previous agent.
2190
2192
 
@@ -2224,7 +2226,8 @@ Rules:
2224
2226
  - content must contain the user-facing answer (you may include structured data as JSON or Markdown inside content).
2225
2227
  - Do NOT add any commentary outside of the JSON. No leading or trailing text.
2226
2228
  - If using tools, still return the final JSON with tool results summarized in content.
2227
- - Human-friendly route names: <friendly>
2229
+ - Human-friendly route names: <names>
2230
+ - Human-friendly route roles (optional): <roles>
2228
2231
 
2229
2232
  <here begins your system instruction>
2230
2233
  ```
@@ -2455,8 +2458,6 @@ Config -> Settings...
2455
2458
 
2456
2459
  - `Store dialog window positions`: Enable or disable dialogs positions store/restore, Default: True.
2457
2460
 
2458
- - `Use theme colors in chat window`: Use color theme in chat window, Default: True.
2459
-
2460
2461
  **Code syntax**
2461
2462
 
2462
2463
  - `Code syntax highlight`: Syntax highlight theme in code blocks. `WebEngine / Chromium` render mode only.
@@ -2523,8 +2524,6 @@ Config -> Settings...
2523
2524
 
2524
2525
  - `Open URLs in built-in browser`: Enable this option to open all URLs in the built-in browser (Chromium) instead of an external browser. Default: False.
2525
2526
 
2526
- - `Convert lists to paragraphs`: If enabled, lists (ul, ol) will be converted to paragraphs (p), Default: True.
2527
-
2528
2527
  - `Model used for auto-summary`: Model used for context auto-summary (generating titles in context list) (default: *gpt-4o-mini*). **Tip:** If you prefer to use local models, you should change the model here as well
2529
2528
 
2530
2529
  **Remote tools**
@@ -3724,6 +3723,20 @@ may consume additional tokens that are not displayed in the main window.
3724
3723
 
3725
3724
  ## Recent changes:
3726
3725
 
3726
+ **2.6.62 (2025-09-26)**
3727
+
3728
+ - Enhanced agent workflow execution.
3729
+ - Improved preset list handling by adding a drop field indicator and fixing auto-scroll.
3730
+ - Added middle-mouse button panning to Painter.
3731
+ - Added an input character counter.
3732
+
3733
+ **2.6.61 (2025-09-26)**
3734
+
3735
+ - Enhanced the agents node editor, custom agent flow, and instruction following.
3736
+ - Added drag-and-drop and reordering functionality to the presets list.
3737
+ - Added statistics for response tokens, including time elapsed and tokens per second.
3738
+ - Improved UI/UX.
3739
+
3727
3740
  **2.6.60 (2025-09-25)**
3728
3741
 
3729
3742
  - Added a new tool: Agents Builder - allowing visual design of agent workflows using nodes - available in Tools -> Agents Builder (beta).
@@ -3744,93 +3757,6 @@ may consume additional tokens that are not displayed in the main window.
3744
3757
  - Improved: The local web search plugin has been enhanced to retrieve multiple URLs at once.
3745
3758
  - Added: Use proxy switch in Settings.
3746
3759
 
3747
- **2.6.56 (2025-09-22)**
3748
-
3749
- - Optimized: Memory usage and performance in streaming and rendering large contexts.
3750
- - Added: Copy to clipboard functionality in user messages.
3751
- - Added: Manual scroll in plain-text mode.
3752
-
3753
- **2.6.55 (2025-09-18)**
3754
-
3755
- - Fixed: Unnecessary context loading from the database.
3756
- - Optimized: Token count in the input field.
3757
-
3758
- **2.6.54 (2025-09-18)**
3759
-
3760
- - Added: Remote tools (like web search) are now also available in the Chat with Files and Agents (LlamaIndex) modes.
3761
- - Added: Two new plugins: Wolfram Alpha and OpenStreetMap.
3762
- - Fixed: Enabled local file-like schemes in links/images in the markdown-it parser.
3763
-
3764
- **2.6.53 (2025-09-17)**
3765
-
3766
- - Added: An icon to enable/disable the web search remote tool in the icon bar, along with remote web search functionality in OpenRouter (#135).
3767
- - Added: The ability to mute audio in real-time mode via the audio icon.
3768
-
3769
- **2.6.52 (2025-09-17)**
3770
-
3771
- - Added MCP plugin: Provides access to remote tools via the Model Context Protocol (MCP), including stdio, SSE, and Streamable HTTP transports, with per-server allow/deny filtering, Authorization header support, and a tools cache.
3772
- - Fixed: tab tooltips reload on profile switch.
3773
-
3774
- **2.6.51 (2025-09-16)**
3775
-
3776
- - Fix: Automatically reloading calendar notes.
3777
- - Fix: Context menu CSS background color for calendar items.
3778
-
3779
- **2.6.50 (2025-09-16)**
3780
-
3781
- - Optimized: Improved memory cleanup when switching profiles and unloading tabs.
3782
- - Fix: Resolved missing PID data in text output.
3783
- - Fix: Enhanced real-time parsing of execute tags.
3784
-
3785
- **2.6.49 (2025-09-16)**
3786
-
3787
- - Fixed: Occasional crashes when focusing on an output container unloaded from memory in the second column.
3788
-
3789
- **2.6.48 (2025-09-15)**
3790
-
3791
- - Added: auto-loading of next items to the list of contexts when scrolling to the end of the list.
3792
-
3793
- **2.6.47 (2025-09-15)**
3794
-
3795
- - Improved: Parsing of custom markup tags.
3796
- - Optimized: Switching profiles.
3797
-
3798
- **2.6.46 (2025-09-15)**
3799
-
3800
- - Added: Global proxy settings for all API SDKs.
3801
- - Fixed: xAI client configuration in Chat with Files.
3802
- - Fixed: Top margin in streaming container.
3803
- - Refactored: Debug workers.
3804
-
3805
- **2.6.45 (2025-09-13)**
3806
-
3807
- - Improved: Parsing of custom markup in the stream.
3808
- - Improved: Message block parsing moved to JavaScript.
3809
-
3810
- **2.6.44 (2025-09-12)**
3811
-
3812
- - Added: Auto-collapse for large user input blocks.
3813
- - Added: Configuration for syntax highlighting intervals.
3814
- - Improved: Visibility of label icons.
3815
- - Improved: Scrolling of code blocks.
3816
- - Fixed: Parsing of quotes in custom markdown blocks.
3817
-
3818
- **2.6.43 (2025-09-12)**
3819
-
3820
- - Fixed: preset restoration when switching profiles.
3821
- - Improved: faster application launch and exit.
3822
-
3823
- **2.6.42 (2025-09-11)**
3824
-
3825
- - Fixed: Save/load zoom factor in the chat window when switched via Ctrl + mouse wheel.
3826
- - Fixed: Break the first line in code blocks.
3827
- - Added: Configuration options for syntax highlight limits.
3828
- - Updated: SVG icons.
3829
-
3830
- **2.6.41 (2025-09-11)**
3831
-
3832
- - Rendering engine optimizations: markdown parsing moved to JS, reduced CPU usage, added auto-memory clearing, and more.
3833
-
3834
3760
  # Credits and links
3835
3761
 
3836
3762
  **Official website:** <https://pygpt.net>