npcsh 0.3.30__py3-none-any.whl → 0.3.32__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 (53) hide show
  1. npcsh/audio.py +540 -181
  2. npcsh/audio_gen.py +1 -0
  3. npcsh/cli.py +37 -19
  4. npcsh/conversation.py +14 -251
  5. npcsh/dataframes.py +13 -5
  6. npcsh/helpers.py +5 -0
  7. npcsh/image.py +2 -4
  8. npcsh/image_gen.py +38 -38
  9. npcsh/knowledge_graph.py +4 -4
  10. npcsh/llm_funcs.py +517 -349
  11. npcsh/npc_compiler.py +44 -23
  12. npcsh/npc_sysenv.py +5 -0
  13. npcsh/npc_team/npcsh.ctx +8 -2
  14. npcsh/npc_team/tools/generic_search.tool +9 -1
  15. npcsh/plonk.py +2 -2
  16. npcsh/response.py +131 -482
  17. npcsh/search.py +20 -9
  18. npcsh/serve.py +210 -203
  19. npcsh/shell.py +78 -80
  20. npcsh/shell_helpers.py +513 -102
  21. npcsh/stream.py +87 -554
  22. npcsh/video.py +5 -2
  23. npcsh/video_gen.py +69 -0
  24. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/generic_search.tool +9 -1
  25. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/npcsh.ctx +8 -2
  26. npcsh-0.3.32.dist-info/METADATA +779 -0
  27. npcsh-0.3.32.dist-info/RECORD +78 -0
  28. npcsh-0.3.30.dist-info/METADATA +0 -1862
  29. npcsh-0.3.30.dist-info/RECORD +0 -76
  30. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/bash_executer.tool +0 -0
  31. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/calculator.tool +0 -0
  32. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/celona.npc +0 -0
  33. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/code_executor.tool +0 -0
  34. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/corca.npc +0 -0
  35. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/eriane.npc +0 -0
  36. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/foreman.npc +0 -0
  37. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/image_generation.tool +0 -0
  38. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/lineru.npc +0 -0
  39. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/local_search.tool +0 -0
  40. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/maurawa.npc +0 -0
  41. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/npcsh_executor.tool +0 -0
  42. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/raone.npc +0 -0
  43. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/screen_cap.tool +0 -0
  44. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/sibiji.npc +0 -0
  45. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/slean.npc +0 -0
  46. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/sql_executor.tool +0 -0
  47. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/test_pipeline.py +0 -0
  48. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/turnic.npc +0 -0
  49. {npcsh-0.3.30.data → npcsh-0.3.32.data}/data/npcsh/npc_team/welxor.npc +0 -0
  50. {npcsh-0.3.30.dist-info → npcsh-0.3.32.dist-info}/WHEEL +0 -0
  51. {npcsh-0.3.30.dist-info → npcsh-0.3.32.dist-info}/entry_points.txt +0 -0
  52. {npcsh-0.3.30.dist-info → npcsh-0.3.32.dist-info}/licenses/LICENSE +0 -0
  53. {npcsh-0.3.30.dist-info → npcsh-0.3.32.dist-info}/top_level.txt +0 -0
npcsh/shell.py CHANGED
@@ -30,7 +30,7 @@ except:
30
30
  print("Could not load the sentence-transformers package.")
31
31
  # Local imports
32
32
 
33
- from .npc_sysenv import (
33
+ from npcsh.npc_sysenv import (
34
34
  get_system_message,
35
35
  lookup_provider,
36
36
  NPCSH_STREAM_OUTPUT,
@@ -39,13 +39,13 @@ from .npc_sysenv import (
39
39
  NPCSH_API_URL,
40
40
  )
41
41
 
42
- from .command_history import (
42
+ from npcsh.command_history import (
43
43
  CommandHistory,
44
44
  start_new_conversation,
45
45
  save_conversation_message,
46
46
  save_attachment_to_message,
47
47
  )
48
- from .llm_funcs import (
48
+ from npcsh.llm_funcs import (
49
49
  execute_llm_command,
50
50
  execute_llm_question,
51
51
  generate_image,
@@ -53,14 +53,14 @@ from .llm_funcs import (
53
53
  get_conversation,
54
54
  get_system_message,
55
55
  )
56
- from .search import rag_search, search_web
57
- from .helpers import (
56
+ from npcsh.search import rag_search, search_web
57
+ from npcsh.helpers import (
58
58
  load_all_files,
59
59
  setup_npcsh_config,
60
60
  is_npcsh_initialized,
61
61
  initialize_base_npcs_if_needed,
62
62
  )
63
- from .shell_helpers import (
63
+ from npcsh.shell_helpers import (
64
64
  complete, # For command completion
65
65
  readline_safe_prompt,
66
66
  get_multiline_input,
@@ -70,7 +70,7 @@ from .shell_helpers import (
70
70
  render_code_block,
71
71
  orange, # For colored prompt
72
72
  )
73
- from .npc_compiler import (
73
+ from npcsh.npc_compiler import (
74
74
  NPCCompiler,
75
75
  load_tools_from_directory,
76
76
  NPC,
@@ -78,7 +78,7 @@ from .npc_compiler import (
78
78
  )
79
79
 
80
80
  import argparse
81
- from .serve import (
81
+ from npcsh.serve import (
82
82
  start_flask_server,
83
83
  )
84
84
  import importlib.metadata # Python 3.8+
@@ -407,88 +407,86 @@ def main() -> None:
407
407
  )
408
408
 
409
409
  str_output = ""
410
- if NPCSH_STREAM_OUTPUT and hasattr(output, "__iter__"):
410
+ try:
411
+ if NPCSH_STREAM_OUTPUT and hasattr(output, "__iter__"):
411
412
 
412
- buffer = ""
413
- in_code = False
414
- code_buffer = ""
413
+ buffer = ""
414
+ in_code = False
415
+ code_buffer = ""
415
416
 
416
- for chunk in output:
417
+ for chunk in output:
417
418
 
418
- if provider == "anthropic":
419
- chunk_content = (
420
- chunk.delta.text
421
- if chunk.type == "content_block_delta"
422
- else None
423
- )
424
- elif provider in ["openai", "deepseek", "openai-like"]:
425
419
  chunk_content = "".join(
426
420
  c.delta.content for c in chunk.choices if c.delta.content
427
421
  )
428
- elif provider == "ollama":
429
- chunk_content = chunk["message"]["content"]
430
- else:
431
- continue
422
+ if not chunk_content:
423
+ continue
424
+
425
+ str_output += chunk_content
426
+ # print(str_output, "str_output")
427
+ # Process the content character by character
428
+ for char in chunk_content:
429
+ buffer += char
430
+
431
+ # Check for triple backticks
432
+ if buffer.endswith("```"):
433
+ if not in_code:
434
+ # Start of code block
435
+ in_code = True
436
+ # Print everything before the backticks
437
+ print(buffer[:-3], end="")
438
+ buffer = ""
439
+ code_buffer = ""
440
+ else:
441
+ # End of code block
442
+ in_code = False
443
+ # Remove the backticks from the end of the buffer
444
+ buffer = buffer[:-3]
445
+ # Add buffer to code content and render
446
+ code_buffer += buffer
447
+
448
+ # Check for and strip language tag
449
+ if (
450
+ "\n" in code_buffer
451
+ and code_buffer.index("\n") < 15
452
+ ):
453
+ first_line, rest = code_buffer.split("\n", 1)
454
+ if (
455
+ first_line.strip()
456
+ and not "```" in first_line
457
+ ):
458
+ code_buffer = rest
432
459
 
433
- if not chunk_content:
434
- continue
460
+ # Render the code block
461
+ render_code_block(code_buffer)
435
462
 
436
- str_output += chunk_content
437
- # print(str_output, "str_output")
438
- # Process the content character by character
439
- for char in chunk_content:
440
- buffer += char
441
-
442
- # Check for triple backticks
443
- if buffer.endswith("```"):
444
- if not in_code:
445
- # Start of code block
446
- in_code = True
447
- # Print everything before the backticks
448
- print(buffer[:-3], end="")
449
- buffer = ""
450
- code_buffer = ""
463
+ # Reset buffers
464
+ buffer = ""
465
+ code_buffer = ""
466
+ elif in_code:
467
+ # Just add to code buffer
468
+ code_buffer += char
469
+ if len(buffer) >= 3: # Keep buffer small while in code
470
+ buffer = buffer[-3:]
451
471
  else:
452
- # End of code block
453
- in_code = False
454
- # Remove the backticks from the end of the buffer
455
- buffer = buffer[:-3]
456
- # Add buffer to code content and render
457
- code_buffer += buffer
458
-
459
- # Check for and strip language tag
460
- if "\n" in code_buffer and code_buffer.index("\n") < 15:
461
- first_line, rest = code_buffer.split("\n", 1)
462
- if first_line.strip() and not "```" in first_line:
463
- code_buffer = rest
464
-
465
- # Render the code block
466
- render_code_block(code_buffer)
467
-
468
- # Reset buffers
469
- buffer = ""
470
- code_buffer = ""
471
- elif in_code:
472
- # Just add to code buffer
473
- code_buffer += char
474
- if len(buffer) >= 3: # Keep buffer small while in code
475
- buffer = buffer[-3:]
476
- else:
477
- # Regular text - print if buffer gets too large
478
- if len(buffer) > 100:
479
- print(buffer[:-3], end="")
480
- buffer = buffer[
481
- -3:
482
- ] # Keep last 3 chars to check for backticks
483
-
484
- # Handle any remaining content
485
- if in_code:
486
- render_code_block(code_buffer)
487
- else:
488
- print(buffer, end="")
472
+ # Regular text - print if buffer gets too large
473
+ if len(buffer) > 100:
474
+ print(buffer[:-3], end="")
475
+ buffer = buffer[
476
+ -3:
477
+ ] # Keep last 3 chars to check for backticks
478
+
479
+ # Handle any remaining content
480
+ if in_code:
481
+ render_code_block(code_buffer)
482
+ else:
483
+ print(buffer, end="")
484
+
485
+ if str_output:
486
+ output = str_output
487
+ except:
488
+ output = None
489
489
 
490
- if str_output:
491
- output = str_output
492
490
  print("\n")
493
491
 
494
492
  if isinstance(output, str):