pygpt-net 2.5.10__py3-none-any.whl → 2.5.11__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.
pygpt_net/CHANGELOG.txt CHANGED
@@ -1,3 +1,10 @@
1
+ 2.5.11 (2025-06-21)
2
+
3
+ - Added a new models: OpenAI o1-pro and o3-pro, Anthropic Claude 4.0 Opus and Claude 4.0 Sonnet, Alibaba Qwen and Qwen2.
4
+ - Updated Bielik model from v2.2 to v2.3 / merged PR #101.
5
+ - Fixed HTML output formatting.
6
+ - Fixed empty index in chat mode.
7
+
1
8
  2.5.10 (2025-03-06)
2
9
 
3
10
  - Added a new model: Claude 3.7 Sonnet.
pygpt_net/__init__.py CHANGED
@@ -6,15 +6,15 @@
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.03.06 02:00:00 #
9
+ # Updated Date: 2025-06-21 02:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  __author__ = "Marcin Szczygliński"
13
13
  __copyright__ = "Copyright 2025, Marcin Szczygliński"
14
14
  __credits__ = ["Marcin Szczygliński"]
15
15
  __license__ = "MIT"
16
- __version__ = "2.5.10"
17
- __build__ = "2025-03-06"
16
+ __version__ = "2.5.11"
17
+ __build__ = "2025-06-21"
18
18
  __maintainer__ = "Marcin Szczygliński"
19
19
  __github__ = "https://github.com/szczyglis-dev/py-gpt"
20
20
  __report__ = "https://github.com/szczyglis-dev/py-gpt/issues"
@@ -6,7 +6,7 @@
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.01.31 19:00:00 #
9
+ # Updated Date: 2025.06.21 23:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
@@ -271,9 +271,8 @@ class Chat:
271
271
 
272
272
  # check if index is empty
273
273
  if index:
274
- nodes = index.docstore.docs.values()
275
- if not nodes:
276
- use_index = False
274
+ pass
275
+ # TODO: implement check if index is empty
277
276
 
278
277
  # TODO: if multimodal support, try to get multimodal provider
279
278
  # if model.is_multimodal():
@@ -306,7 +305,13 @@ class Chat:
306
305
  response = chat_engine.stream_chat(query)
307
306
  else:
308
307
  response = chat_engine.chat(query)
309
- else:
308
+
309
+ # check for not empty
310
+ if len(response.source_nodes) == 0:
311
+ self.log("No source nodes found in response, using LLM directly...")
312
+ use_index = False
313
+
314
+ if not use_index:
310
315
  # TOOLS: commands are applied to system prompt here
311
316
  # prepare tools (native calls if enabled)
312
317
  tools = self.window.core.agents.tools.prepare(context, extra)
@@ -3,10 +3,10 @@
3
3
  # ================================================== #
4
4
  # This file is a part of PYGPT package #
5
5
  # Website: https://pygpt.net #
6
- # GitHub: https://github.com/szczyglis-dev/py-gpt #
6
+ # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2025.06.21 16:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  from datetime import datetime
@@ -283,12 +283,11 @@ class Renderer(BaseRenderer):
283
283
  if urls_str:
284
284
  self.append_raw(meta, item, "\n" + "\n".join(urls_str))
285
285
 
286
- # docs json
287
286
  if self.window.core.config.get('ctx.sources'):
288
287
  if item.doc_ids is not None and len(item.doc_ids) > 0:
289
288
  try:
290
289
  docs = self.body.get_docs_html(item.doc_ids)
291
- self.get_output_node(meta).append(docs)
290
+ self.append_raw(meta, item, docs)
292
291
  self.to_end(meta)
293
292
  except Exception as e:
294
293
  pass
@@ -345,7 +344,6 @@ class Renderer(BaseRenderer):
345
344
  Append block to output
346
345
 
347
346
  :param meta: context meta
348
- :param ctx: context item
349
347
  """
350
348
  node = self.get_output_node(meta)
351
349
  cursor = node.textCursor()
@@ -362,7 +360,7 @@ class Renderer(BaseRenderer):
362
360
  text: str
363
361
  ):
364
362
  """
365
- Append and format raw text to output
363
+ Append and format raw text to output as plain text.
366
364
 
367
365
  :param meta: context meta
368
366
  :param ctx: context item
@@ -373,7 +371,7 @@ class Renderer(BaseRenderer):
373
371
  if prev_text != "":
374
372
  prev_text += "\n\n"
375
373
  new_text = prev_text + text.strip()
376
- node.setText(new_text)
374
+ node.setPlainText(new_text)
377
375
  cur = node.textCursor() # Move cursor to end of text
378
376
  cur.movePosition(QTextCursor.End)
379
377
 
@@ -412,7 +410,7 @@ class Renderer(BaseRenderer):
412
410
  end: str = "\n"
413
411
  ):
414
412
  """
415
- Append text to output
413
+ Append text to output.
416
414
 
417
415
  :param meta: context meta
418
416
  :param ctx: context item
@@ -425,10 +423,10 @@ class Renderer(BaseRenderer):
425
423
  s = str(text) + end
426
424
  while s:
427
425
  head, sep, s = s.partition("\n") # Split line at LF
428
- cur.insertText(head) # Insert text at cursor
429
- if sep: # New line if LF
426
+ cur.insertText(head)
427
+ if sep:
430
428
  cur.insertText("\n")
431
- node.setTextCursor(cur) # Update visible cursor
429
+ node.setTextCursor(cur)
432
430
 
433
431
  def append_timestamp(
434
432
  self,
@@ -502,12 +500,14 @@ class Renderer(BaseRenderer):
502
500
  meta: Optional[CtxMeta] = None
503
501
  ) -> ChatOutput:
504
502
  """
505
- Get output node for current context
503
+ Get output node for current context.
506
504
 
507
505
  :param meta: context meta
508
506
  :return: output node
509
507
  """
510
- return self.window.core.ctx.output.get_current_plain(meta)
508
+ node = self.window.core.ctx.output.get_current_plain(meta)
509
+ node.setAcceptRichText(False)
510
+ return node
511
511
 
512
512
  def get_input_node(self) -> ChatInput:
513
513
  """
@@ -533,4 +533,4 @@ class Renderer(BaseRenderer):
533
533
  node.setStyleSheet("")
534
534
  node.document().setMarkdown("")
535
535
  node.document().setHtml("")
536
- node.setPlainText("")
536
+ node.setPlainText("")
@@ -6,7 +6,7 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2025.06.21 16:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import os
@@ -379,15 +379,6 @@ class Body:
379
379
  <style>
380
380
  """ + self.prepare_styles() + """
381
381
  </style>
382
- </head>
383
- <body """ + classes_str + """>
384
- <div id="container">
385
- <div id="_nodes_" class="nodes empty_list"></div>
386
- <div id="_append_input_" class="append_input"></div>
387
- <div id="_append_output_" class="append_output"></div>
388
- <div id="_footer_" class="footer"></div>
389
- </div>
390
-
391
382
  <link rel="stylesheet" href="qrc:///css/katex.min.css">
392
383
  <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
393
384
  <script type="text/javascript" src="qrc:///js/highlight.min.js"></script>
@@ -418,6 +409,17 @@ class Body:
418
409
  window.location.href = 'bridge://focus';
419
410
  }
420
411
  });
412
+ function sanitize(content) {
413
+ var parser = new DOMParser();
414
+ var doc = parser.parseFromString(content, "text/html");
415
+ var codeElements = doc.querySelectorAll('code, pre');
416
+ codeElements.forEach(function(element) {
417
+ var html = element.outerHTML;
418
+ var newHtml = html.replace(/&amp;lt;/g, '&lt;').replace(/&amp;gt;/g, '&gt;');
419
+ element.outerHTML = newHtml;
420
+ });
421
+ return doc.documentElement.outerHTML;
422
+ }
421
423
  function highlightCode() {
422
424
  document.querySelectorAll('pre code').forEach(el => {
423
425
  if (!el.classList.contains('hljs')) hljs.highlightElement(el);
@@ -458,7 +460,7 @@ class Body:
458
460
  function appendToInput(content) {
459
461
  const element = document.getElementById('_append_input_');
460
462
  if (element) {
461
- element.innerHTML += content;
463
+ element.innerHTML += sanitize(content);
462
464
  }
463
465
  highlightCode();
464
466
  scrollToBottom();
@@ -485,7 +487,7 @@ class Body:
485
487
  msg = box.querySelector('.msg');
486
488
  }
487
489
  if (msg) {
488
- msg.innerHTML+= content;
490
+ msg.innerHTML+= sanitize(content);
489
491
  }
490
492
  }
491
493
  highlightCode();
@@ -496,7 +498,7 @@ class Body:
496
498
  const element = document.getElementById('_nodes_');
497
499
  if (element) {
498
500
  element.classList.remove('empty_list');
499
- element.innerHTML += content;
501
+ element.innerHTML += sanitize(content);
500
502
  }
501
503
  highlightCode();
502
504
  scrollToBottom();
@@ -507,7 +509,7 @@ class Body:
507
509
  if (element) {
508
510
  const extra = element.querySelector('.msg-extra');
509
511
  if (extra) {
510
- extra.innerHTML+= content;
512
+ extra.innerHTML+= sanitize(content);
511
513
  }
512
514
  }
513
515
  highlightCode();
@@ -566,7 +568,7 @@ class Body:
566
568
  msg = box.querySelector('.msg');
567
569
  }
568
570
  if (msg) {
569
- msg.innerHTML = content;
571
+ msg.innerHTML = sanitize(content);
570
572
  }
571
573
  }
572
574
  highlightCode();
@@ -580,7 +582,7 @@ class Body:
580
582
  const last = elements[elements.length - 1];
581
583
  const contentEl = last.querySelector('.content');
582
584
  if (contentEl) {
583
- contentEl.innerHTML += content;
585
+ contentEl.innerHTML += sanitize(content);
584
586
  }
585
587
  }
586
588
  }
@@ -592,7 +594,7 @@ class Body:
592
594
  const last = elements[elements.length - 1];
593
595
  const contentEl = last.querySelector('.content');
594
596
  if (contentEl) {
595
- contentEl.innerHTML = content;
597
+ contentEl.innerHTML = sanitize(content);
596
598
  }
597
599
  }
598
600
  }
@@ -795,6 +797,14 @@ class Body:
795
797
  });
796
798
  });
797
799
  </script>
800
+ </head>
801
+ <body """ + classes_str + """>
802
+ <div id="container">
803
+ <div id="_nodes_" class="nodes empty_list"></div>
804
+ <div id="_append_input_" class="append_input"></div>
805
+ <div id="_append_output_" class="append_output"></div>
806
+ <div id="_footer_" class="footer"></div>
807
+ </div>
798
808
  </body>
799
809
  </html>
800
810
  """
@@ -6,7 +6,7 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2024.12.14 08:00:00 #
9
+ # Updated Date: 2025.06.21 16:00:00 #
10
10
  # ================================================== #
11
11
 
12
12
  import json
@@ -362,6 +362,8 @@ class Renderer(BaseRenderer):
362
362
 
363
363
  self.update_names(meta, ctx)
364
364
  raw_chunk = str(text_chunk)
365
+ raw_chunk = raw_chunk.replace("<", "&lt;")
366
+ raw_chunk = raw_chunk.replace(">", "&gt;")
365
367
  if begin:
366
368
  # debug
367
369
  debug = ""
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "__meta__": {
3
- "version": "2.5.10",
4
- "app.version": "2.5.10",
5
- "updated_at": "2025-03-06T00:00:00"
3
+ "version": "2.5.11",
4
+ "app.version": "2.5.11",
5
+ "updated_at": "2025-06-21T00:00:00"
6
6
  },
7
7
  "access.audio.event.speech": false,
8
8
  "access.audio.event.speech.disabled": [],